How can I separate a string that has white spaces between the 3 shorts and between the rest of the string to 4 different strings.
Example:
"123 402 10 aaa bbb cc".
What I want is simply
short i=123;
short j=402;
short y=10;
char * c="aaa bbb cc".
I was trying to use sscanf to do it but I can’t seem to get the hang of getting that last string to work cause of the white space.
You don’t need
sscanf. You can usestrchrto find the spaces,atoito turn strings into integers, and simple assignment to turn the spaces into terminating zeroes.You can also do this:
Yields:
i=123 j=402 y=10 c='aaa bbb cc'