OK For example, I have this line in my txt file:
1|1,12;7,19;6,4;8,19;2,2
As you can see, it consists of two parts, separated by the symbol | . I have no problem getting both parts and splitting the second part 1,12;7,19;6,4;8,19;2,2 using a separator ; . BUT I am having problems with further separation, to get the first and second number of each set.
This is my current code:
result = strtok(result, ";"); while(result != NULL ) { printf("%s\n", result); result = strtok(NULL, ";"); }
He leads me out:
1.12
7.19
6.4
8.19
2.2
Good Excellent. But when I try "strtok" (I use this method for separation) for example:
result = strtok(result, ";"); while(result != NULL ) { //printf("%s\n", result); help = strtok(result, ","); while(help != NULL) { printf("<%s>", help); help = strtok(NULL, ","); } result = strtok(NULL, ";"); }
I get only "<1>, <12>", as if there is only one set in this set of numbers. I donβt understand where the rest of the numbers are. Instead, the output should be: <1 <12> <7> <19> <6 <4>, <8 <19 <, <2>. Can someone please give a decision how to get EVERY number from each set of this set of numbers. Maybe there are other methods, or I'm doing something wrong :)
Thanks!
c string split strtok
Dmitri
source share