Create a program that counts the number of words in a given string.
MediumProblem Statement
Create a program that counts the number of words in a given string.
Sample Input
std::string str = "Count the number of words in this string";
Sample Output
Word Count = 8
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <iostream>
#include <sstream>
#include <string>
int main() {
std::string str = "Count the number of words in this string";
// Logic to count words
return 0;
}
Input
std::string str = "Count the number of words in this string";
Expected Output
Word Count = 8