Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The program reads lines of input and prints out paragraphs. The line length for each output line may be specified as a command line argument.
The program reads lines of input and prints out paragraphs. The line length for each output line may be specified as a command line argument. If no command line argument for the line length is specified, the program should use a line length of The number of spaces to indent each paragraph may be specified as a command line argument. If no command line argument for indent is specified, the programn should use an indent of 8. Words in the output are separated by a single whitespace character. So, for example, the input "Hello world should appear as "Hello world' in the output. One or more consecutive empty or blank lines, or the end of file, should be interpreted as the end of a paragraph. Several consecutive empty or blank lines should cause a single empty line to be generated on output. The output must be filled out to a length less than or equal to the line length. This may involve combining several lines of input into a single line of output. For example, assume we have an input file like so This is my favorite class Of all timell Really, I swear! If the indent is 5, and the line length is 80, then the output will be This is my favorite class. Of all timel Really, I swear Notice that we combined the first two lines of input into a single line of output, we deleted the multiple spaces between This and is, we indented 5 spaces, and we combined multiple blank lines into a single line between paragraphs Whitespace at the beginning and end of a line of input should be ignored. Note that the length of the output line should not exceed the line length. The only exception to this rule is if there is only a single word on the output line. For example, suppose we have an indent value of 10, a line length of 15, and input as follows: Several of us just locooo000000000000oVe C++! The output would be Several of us just looooo00000000000oove C++! Observe that we ignored the leading spaces in the first line of input. Note also that the first and third lines of output exceed the line length of 15, because there is only one word in the output line, this is acceptable. The second line of output does not have "loo000000000000000ove on the line because adding it would cause the output line to exceed the line length Variables used for the code: Command line arguments LL --> output line length set to n. IN --> indentation set to n. filename --> name of file opneed and read.for input. use: int main (int arge, char* argv[]) I/Note: if no filename is provided, the program should read from standard input. // You are allow to use multiple LL and in flag arguments. If LL=5 LL=20, // result in a line length of 20 (last command line argument is used). The program reads lines of input and prints out paragraphs. The line length for each output line may be specified as a command line argument. If no command line argument for the line length is specified, the program should use a line length of The number of spaces to indent each paragraph may be specified as a command line argument. If no command line argument for indent is specified, the programn should use an indent of 8. Words in the output are separated by a single whitespace character. So, for example, the input "Hello world should appear as "Hello world' in the output. One or more consecutive empty or blank lines, or the end of file, should be interpreted as the end of a paragraph. Several consecutive empty or blank lines should cause a single empty line to be generated on output. The output must be filled out to a length less than or equal to the line length. This may involve combining several lines of input into a single line of output. For example, assume we have an input file like so This is my favorite class Of all timell Really, I swear! If the indent is 5, and the line length is 80, then the output will be This is my favorite class. Of all timel Really, I swear Notice that we combined the first two lines of input into a single line of output, we deleted the multiple spaces between This and is, we indented 5 spaces, and we combined multiple blank lines into a single line between paragraphs Whitespace at the beginning and end of a line of input should be ignored. Note that the length of the output line should not exceed the line length. The only exception to this rule is if there is only a single word on the output line. For example, suppose we have an indent value of 10, a line length of 15, and input as follows: Several of us just locooo000000000000oVe C++! The output would be Several of us just looooo00000000000oove C++! Observe that we ignored the leading spaces in the first line of input. Note also that the first and third lines of output exceed the line length of 15, because there is only one word in the output line, this is acceptable. The second line of output does not have "loo000000000000000ove on the line because adding it would cause the output line to exceed the line length Variables used for the code: Command line arguments LL --> output line length set to n. IN --> indentation set to n. filename --> name of file opneed and read.for input. use: int main (int arge, char* argv[]) I/Note: if no filename is provided, the program should read from standard input. // You are allow to use multiple LL and in flag arguments. If LL=5 LL=20, // result in a line length of 20 (last command line argument is used)
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