cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Read part char
Read part char
Jan 19, 2011 at 11:53am UTC
Icenel
(31)
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
Jan 19, 2011 at 11:59am UTC
Moschops
(7244)
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.
Jan 19, 2011 at 12:06pm UTC
quirkyusername
(792)
it's easy using strings
http://www.cplusplus.com/reference/string/string/find/
http://www.cplusplus.com/reference/string/string/substr/
Topic archived. No new replies allowed.