Question: Write a C program that counts the number of characters, words and lines read from standard input until EOF is reached. Assume the input is

Write a C program that counts the number of characters, words and lines read from standard input until EOF is reached. Assume the input is ASCII text of any length. Every byte read from stdin counts as a character except EOF. Words are defined as contiguous sequences of letters (a through z, A through Z) and the apostrophe ( ', value 39 decimal) separated by any character outside these ranges. Lines are defined as contiguous sequences of characters separated by newline characters (' '). Characters beyond the final newline character will not be included in the line count. On reaching EOF, use this output command: printf( "%lu %lu %lu ", charcount, wordcount, linecount ); Where charcount, wordcount and linecount are all of type unsigned long int. You may need these large types to handle long documents. You may find the standard library function getchar() useful.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!