If you have a string as below
str="insert 111,name,123456789"
when you pass it to strtok and try to print the values, they are output in reverse.
For example:
char* token=strtok(str," ");
printf("%s %s %s %s\n",token,strtok(NULL,","),strtok(NULL,","),strtok(NULL,","));
output: insert 1234567 name 1111
instead of:insert 111 name 123456789
Why is this happening? How can this be fixed?