Ok I need some help on building a program that is able to count the number of wo
ID: 441033 • Letter: O
Question
Ok I need some help on building a program that is able to count the number of words and sentence in a program. The current build I have is something amongst the line of
#include <iostream>
#include <string>
using namespace std;
int main()
{
string sentence
int wordcount;
int sentencecount;
while (cin >> sentence)
{
for(int i = 0; i < sentence.size(); i++)
{
if(sentence(i) == ' ')
{
wordcount++;
But from here, the program fails. So if possible, can someone write down the code to find word count and sentence count, using a style similar to the one I am providing?
Will rate upon the one that can complete this program similar to this fashion.