Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions