Question: This should be a C++ program that works on X-Code Word Count Write a function called wordcount which takes a string as a parameter and
This should be a C++ program that works on X-Code
Word Count Write a function called wordcount which takes a string as a parameter and returns an int. The function should return the number of words that occur in the given string. For this assignment, consider a "word" to be a sequence of consecutive non-space characters, and words in the string are separated by one or more space characters. For example, if the function is given the string, "Hello, how are you?", the function should return 4 Include your function in a test program which uses a sentinel-controller loop to input a series of sentences, and for each sentence entered report the number of words in the sentence. Use the getline function to input the sentences, as that function inputs an entire line at a time. The program should stop when an empty line is input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
