count word c++
int countWords(string str)
{
// Input: Go Go Ganger
// Output: 3
stringstream s(str);
string word; // to store individual words
int count = 0;
while (s >> word)
count++;
return count;
}
Are there any code examples left?
New code examples in category C++