This is not possible with
strtok
because this function inserts a
NULL
character at the end of the token.
You could do the following to get what you want -
pch = strchr(TempStr, ' ');
pch = strchr(pch + 1, ' ');
pch = strchr(pch + 1, ' ');
pch = strchr(pch + 1, ' ');
Another thing I noticed in your code is that the first time,
strtok
would be called twice before storing in the list.
So you may want to place the
strtok
after the
switch
statement.