Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C language (not c++) Write a program that reads a text file as input and counts the number of sentences and words. The input to
C language (not c++)
Write a program that reads a text file as input and counts the number of sentences and words. The input to your program should be a user specified text file. In other words, obtain the name of the input file at run time from the user of the program. Protect your program against crashes that might be caused by a bad file name. A sentence begins with one of the following: ' 0 '...' 9 ', 'A'...' Z ', or ' a '...' z. A sentence, once started, ends with the first occurrence of one of the following sequences: 1. A TERMINATOR followed by two spaces 2. A TERMINATOR followed by one space and end-of-line 3. A TERMINATOR followed by end-of-line 4. A TERMINATOR followed by a double quote and a space 5. A TERMINATOR followed by a double quote and an end-of-line TERMINATORS: ' '(period) '?' (question mark) 'I' (exclamation point) A word begins with one of the same set of characters that begin a sentence. A word, once started, ends with the first occurrence of a space, a tab, or an end-of-line, unless the end-of-line is preceded by a hyphen. Appropriate counting actions should be taken when the end-of-file (EOF) is encountered. The output total number of sentences and words should be printed to the screen. TIPS: Make two passes through the input file. Count the sentences on one pass, wards on the other. While a good programming practice, functions are NOT required so keep the entire program in the moin function. implement the word counter first because it is, arguably, the easier than the sentence counter. MOST IMPORTANTLY, focus on your algorithm before you implement it with cade. You've been warned Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started