How to split a string(extract words) without stringstream
and strtok
in C++?
I want to split a string that has multiple consecutive spaces between each word, and it may span multiple lines as well have white space before a new line start.
So far I have this but it can only handle one space
while (input.compare(word) != 0)
{
index = input.find_first_of(" ");
word = input.substr(0,index);
names.push_back(word);
input = input.substr(index+1, input.length());
}
Thank you