Answers for "break input stream into words"

C++
0

break input stream into words

int countWords(string str) {
    stringstream s(str);
    string word;
    int count = 0;
    while (s >> word)
        count++;
    return count;
}
Posted by: Guest on April-13-2021

Browse Popular Code Answers by Language