strtok problem in calling

Posted by Moony on Stack Overflow See other posts from Stack Overflow or by Moony
Published on 2010-04-05T20:42:09Z Indexed on 2010/04/05 20:43 UTC
Read the original article Hit count: 287

Filed under:
|

I have a function using strtok like this

void f1(char *name)
{
...
char *tmp;
tmp = strtok(names, " ,");
while(tmp)
{
...
tmp = strtok(NULL, " ,");
}
...
}

And i have a call f1("abc,def");

Problem is that in first call f1 gets abc,def and in 2nd call gets just abc

I am confused.. Why is this so?

© Stack Overflow or respective owner

Related posts about strtok

Related posts about c