Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Write a function that accepts a pointer to a c-string or a function to a character array as its argument and returns the number of words contained in the string

Write a function that accepts a pointer to a c-string or a function to a character array as its argument and returns the number of words contained in the string

Computer Science

Write a function that accepts a pointer to a c-string or a function to a character array as its argument and returns the number of words contained in the string. For example, if the string argument is "It is best to plan my school work every Monday morning", the function should return the number 11

Demonstrate the function in a program that asks the users to input a string and then pass it to the function. The number of words in the string should be displayed on the screen.

Grading Requirements:

Must be in C++

Clean and clear output

Your code should implement at least one function besides the main

Introductory comments as well as comments throughout the program

Should avoid reading spaces before/after and in between words.

I can just enter spaces or nothing, and the result should be zero.

Sample output:

Enter a C-string containing 80 or fewer characters: It is best to plan your school work every Monday
morning The number of words in the C-string: 11

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE