Read part char

1
2
   char name[30] = "Edward Anthony Coln";
  


how I can get the word "Edward", "Anthony", "Coln" ?

Please let me know the ways for that 3 words

Thank you
You can use the strtok function, with your delimiting character as " " (i.e. a space).

http://www.cplusplus.com/reference/clibrary/cstring/strtok/

It's a little tricky to get used to; the first time you call it, feed in the char* you want to tokenise, but on each subsequent call on the same string, you have to pass in NULL and it will keep going where it left off.
Topic archived. No new replies allowed.