strtok
is working exactly as expected. It breaks the input apart into the strings 123
and 456
.
strtok (tempRead, " "); /* Returns 123 */
strtok (NULL, " "); /* Returns 456 */
I think you can do with a simpler solution:
int i = 0;
char tempRead[30];
...
while (tempRead[i] == ' ' && tempRead[i])
i++;
strcpy(str,tempRead+i);
solved strtok not working as expected