Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 Counting Words This task requires writing a C program which reads text from standard input (one character at a time), then, after all of

image text in transcribed

3 Counting Words This task requires writing a C program which reads text from standard input (one character at a time), then, after all of the input has been read (signaled by the # character), prints a single line of output containing the number of characters, number of lines and number of words in the input A 'word' is defined in the same way as for the previous program. The output must be formatted exactly as shown in the examples below (with the correct count values substituted). Your program must generate no other output besides the output described (including prompts to the user, like Enter some text'). Programs which generate extraneous output will be considered incorredt The submission for this part must be contained in a file called word count.c Examples Examples of the behavior of a correct implementation of word_count.c are shown below. As in the previous section, user input is shown in blue and the program's output is shown in black. Note that the # character, which is used to signal the end of the input, is not counted as a character or part of a word (it is strictly a signifier of the end of the input stream and is otherwise ignored) Example 1 (posted as three_lines.txt) This is a line of text THIS LiNE conTAINS unusual CAPITALization This line contains symbols & lots of spaces Characters: 116, Words: 20, Lines: 3 Example 2 watch out for words at the beginning and end# Characters: 44, Words: 9, Lines: 1 Example 3 and cases where the text begins with spaces instead of words# Characters: 61, Words: 11, Lines: 1 Example 4 And also, watch out for cases where the # character is followed by more input (which must be ignored) Characters: 41, Words: 8, Lines: 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions