Answers for "count word c++"

C++
-1

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;
}
Posted by: Guest on April-16-2021

Browse Popular Code Answers by Language