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

Requirements 1. Write a C program that counts the number of characters, words and lines read from standard input until EOF is reached. 2. Assume the input is ASCII text of any length. 3. Every byte read from stdin counts as a character except EOF. 4. 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. 5. Lines are defined as contiguous sequences of characters separated by newline characters (' '). 6. Characters beyond the final newline character will not be included in the line count. 7. 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. Guide You may find the standard library function getchar() useful. Check it out onlin or read its manpage. There's a handy standard program called wc that does a similar job, but it does not match the requirements exactly it is a little more clever about word boundaries and will sometimes count fewer words than our simple program). Your program should agree with wc's character and line counts, as the logic for those is the same. Escape characters This Q&A on Stack Overflow gives advice on representing the apostrophe character using an escape sequence. Stack Overflow is very useful indeed. Testing and submission Submit your solution as a complete program (i.e. with a main() function) in a C source file called count.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
