I found this example for using strtok() on http://www.cplusplus.com/reference/cstring/strtok/, and don't understand how they are getting from token to token through "pch = strtok (NULL, " ,.-");"
Here is the code:
/* strtok example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," ,.-");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
return 0;
}
Here is the output:
Splitting string "- This, a sample string." into tokens:
This
a
sample
string