Using C++ write a simple text-formatting program that reads a text le and produc
ID: 3755174 • Letter: U
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 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.
Explanation / Answer
#include #include #include #include #include #include using namespace std; int main() { string inputFileName; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.