std::stringstream convertor("Tom Scott 25");
std::string name;
int age;
convertor >> name >> age;
if(convertor.fail())
{
// it fails of course
}
I'd like to extract two or more words to one string variable. So far I've read, it seems that it is not possible. If so, how else to do it? I'd like name
to get all characters before number (the age).
I'd feel most comfortable using sscanf, but I obviously can't.
What I need is ability to extract all words before age
for example.