Split string

May 3, 2014 at 8:10am
Hello how do you split string in C by space?

I have:

char * string;
May 3, 2014 at 9:13am
You can use strtok.
http://www.cplusplus.com/reference/cstring/strtok/
1
2
3
4
for (char* token = strtok(string, " "); token; token = strtok(NULL, " "))
{
	printf("%s\n", token);
}
May 3, 2014 at 9:17am
Thank you.
Topic archived. No new replies allowed.