Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<string.h>
- #include<stdio.h>
- #include <stdlib.h> //contians atoi for string to int conversion
- /*
- * This program is a simple? way of parsing a csv character array
- *
- *
- * */
- int main()
- {
- int x,y,z;
- char input[16] = "545,394,2";
- char *p;
- p = strtok(input, ",");
- if(p){
- x=atoi(p);
- }
- p = strtok(NULL, ",");
- if(p){
- y=atoi(p);
- }
- p = strtok(NULL, ",");
- if(p){
- z=atoi(p);
- }
- printf("X: %d\n", x);
- printf("Y: %d\n", y);
- printf("Z: %d\n", z);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement