strtok giving empty strings
Hello everyone,
I am having a bit of trouble getting strtok to tokenize my string. Here is the bit of code that is giving me trouble:
Code:
printf( "%s\n", temp );
strcpy(h, strtok( temp, ":" ));
strcpy(m, strtok( NULL, ":" ));
strcpy(s, strtok( NULL, ":" ));
printf( "%s,%s,%s\n",h, m, s );
What comes out is this:
Code:
14:30:20.555
14,,20.555
That is, the first and third of the three substrings work perfectly but the middle one gives me an empty string when what I want is the "30".
Why is it doing that, and how do I fix it?
Thanks,
H.