Complete the implementation of the count_chars function, according to the following specification: Parameters: The function
Question:
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.
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi