Question
Using C++ write a simple text-formatting program that reads a text le and produces another text le in which blank lines are removed, multiple blanks
Using C++ write a simple text-formatting program that reads a text le and produces another text le in which blank lines are removed, multiple blanks are replaced with a single blank, and no lines are longer than some given length. Put as many words as possible on the same line. You will have to break some lines of the given le, but do not break any words or put punctuation marks at the beginning of a new line. A sample run to format a text le Lincoln.txt to a new text le Formatted.txt is: Please enter the name of the input file containing unformatted text: Lincoln.txt Please enter the name of the output file to contain formatted text: Formatted.txt Please enter maximum length of line (1 72) 40 Press any key to continue You need to input the given length (between 1 and 72) from keyboard. Your program should check if you can successfully open les for read and write. Download the test input le: Lincoln.txt and compare you output le with the correct output le, Formatted.txt , to verify your program. Read from the input le word by word. Keep track of the number of characters, which is used to decide when to make a new line.
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