std::string token, line("This is a sentence.");
std::istringstream iss(line);
getline(iss, token, ' ');
std::cout << token[0] << "\n";
This is printing individual letters. How do I get the complete words?
Updated to add:
I need to access them as words for doing something like this…
if (word[0] == "something")
do_this();
else
do_that();
To store all the tokens:
or just:
Now
tokens[i]is theith token.