how to count words in c 2b 2b 3f

Solutions on MaxInterview for how to count words in c 2b 2b 3f by the best coders in the world

showing results for - "how to count words in c 2b 2b 3f"
Alessandra
18 May 2018
1int countWords(string str)
2{
3    // Input: Go Go Ganger
4  	// Output: 3
5    stringstream s(str); 
6    string word; // to store individual words
7    int count = 0;
8    while (s >> word)
9        count++;
10    return count;
11}