Question
Complete the implementation of the count_chars function, according to the following specification: Parameters: The function expects no arguments. Returns: The function
Complete the implementation of the count_chars function, according to the following specification:
• Parameters:
• The function expects no arguments.
• Returns:
• The function produces no result (i.e. the return type is void).
• Process:
• Declare an integer variable which will be used to count characters. Initialise the variable to zero.
• Enter a loop which continues indefinitely. Within the loop:
• Read a single character code from standard input. Do not prompt for input. This program is not designed for interactive use.
• If the character code is equal to EOF, break out of the loop.
• Otherwise, increment the counter by 1.
• This is the end of the loop.
• After the loop ends, display the number of characters processed.
Notes:
• The results produced by this program look similar to the following image.
• You can redirect standard input using a pipe (|), or by means of the <, <<, or <<< shell redirection operators. If you are not familiar with the concept, the following web search term will lead you to plenty of information sources: bash input redirection.
• Use this test driver to implement and test your function prior to submission.
Things to do:
• Insert your solution to the problem in the body of the count_chars function.
Things to avoid:
• Do not insert any code into the main function – any changes made to main will be discarded when AMS processes your submission.
Step by Step Solution
3.55 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
Program include void countchars char c int charc...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started