int main ()
{
char str[] =\"kk,12,,23,4,,,3434,3,33,,,\";
char * valarr;
int count=0;
valarr = strtok(str,\",\");
while(valarr != \'\\0\')
{
Correct. The documentation states this pretty clearly:
A sequence of two or more contiguous delimiter characters in the parsed string is considered to be a single delimiter.
That's just how strtok()
is supposed to work. You might be better of rolling your own, which will also free you from strtok()
's nastiness.
Short answer: NO At least using strtok, check this to learn what's better for your application.