Question: Write a C + + program that acts as a simple counting tool for collecting information extracted from a textual file of documents prepared for
Write a C program that acts as a simple counting tool for collecting information extracted from a textual file of documents prepared for a simple word
processing software. An input file for the simple word processor includes three types of data: the general text of the document to be formatted, command
lines, and commented lines. A line that starts with a character and followed by one of the defined commands is referred to as a command line, otherwise
it is just a textual line. While a line that starts by # is a comment line, which it would be skipped by the word processor.
The simple word processing software includes five commands. The commands begin" and end" are used to define the begin and end of a paragraph,
respectively, of the text being formatted as a paragraph. Note that, each end" command should be matched with a begin" command; otherwise, an
error is detected in the input file. The other commands are bold", italic", and underline" which are used for typesetting the following words specified
on the same line. If no command name is found following the character, or the word following the is not recognized as one of the five possible
commands, an error message should be printed out followed by the line number. The text of the document will be structured into sequences of paragraphs
according to the commands that are used to delimit the begin and end of each paragraph. The typesetting commands can eventually appear any number of
times within a paragraph. If there are no commands for structuring the input text into paragraphs, it will be assumed that the whole textual document has
not been structured into paragraphs, and the number of paragraphs is zero. A word is defined as a sequence of one or more nonwhitespace characters
separated by whitespace.
The program should prompt the user for the file name to read from. The program should open the file for reading, and if the file cannot be opened, it should
print out the message "File cannot be opened followed by the filename, and exit. After reading the contents of the input file, the program should print out
the total number of lines, the number of commented lines, the number of the paragraphs, the total number of words, and the number of bold, italic, and
underline commands in the file. See the examples in the class slides for further details.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
