cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Strings using <cstring>
Strings using <cstring>
Dec 2, 2009 at 2:14am UTC
foncused
(24)
If I have a string with no spaces (\0) in it, how can i break up the string into to separate strings:
Say I have cin << fullname (with a comma between last and first names, no spaces)
How can I break up fullname into last_name and first_name?
Dec 2, 2009 at 2:35am UTC
firedraco
(6243)
Your << should be going the first name.
Anyway, just search through the string until you find the ',', then take the first part and strcpy it to last name, then the rest and put it into first name.
Dec 2, 2009 at 1:07pm UTC
Bazzy
(6281)
You can use strtok:
http://www.cplusplus.com/reference/clibrary/cstring/strtok/
Topic archived. No new replies allowed.