std::string token, line("This is a sentence.");
std::istringstream iss(line);
getline(iss, token, ' ');
std::cout << token << "\n";
To save all markers:
std::vector<std::string> tokens;
while (getline(iss, token, ' '))
tokens.push_back(token);
or simply:
std::vector<std::string> tokens;
while (iss >> token)
tokens.push_back(token);
Now tokens[i]this is the ith token .
source
share