Answered step by step
Verified Expert Solution
Link Copied!

Question

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 to Expert-Tailored 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

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions