"terminate input by the line "no more"
"
Yould could read the input by lines, not by words:
#include <iostream>
#include <string>
#include <sstream>
...
std::string line;
while (std::getline(std::cin, line) && line != "no more") {
if (line.empty()) ; // TODO: line might be empty
std::istringstream is(line);
std::string name;
int age;
if (is >> name && is >> age) { /* TODO: store new data */ }
}
If you want to take care of situation when there are additional characters after this no more
then you might use line.substr(0,7) != "no more"
and if you just want to find out if no more
is within the line, not necessarily at the beginning, you can do: line.find("no more") != std::string::npos