Reading multi values from string

1
2
3
4
5
6
string name_age_IQ;
name_age_IQ = Lucas:37:13;

string name;
int age;
int iq;


How do I import:
"Lucas" to string name,
"37" to int age,
and "13" to int IQ?
Last edited on
std::string::substr http://www.cplusplus.com/reference/string/string/substr/ will get you the part of the string you want, and here's a discussion about the best way to convert a string to an int http://www.cplusplus.com/forum/articles/9645/

Thanks!
Topic archived. No new replies allowed.