break input stream into words code example
Example: break input stream into words
int countWords(string str) {
stringstream s(str);
string word;
int count = 0;
while (s >> word)
count++;
return count;
}
int countWords(string str) {
stringstream s(str);
string word;
int count = 0;
while (s >> word)
count++;
return count;
}