Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program that takes input from user if no filename is entered. The program is instructed as to which options it should use by way
C++ program that takes input from user if no filename is entered.
The program is instructed as to which options it should use by way of command line arguments. Command line argument Meaning -LL:n The output line length should be set to n. The value of n must be a positive integer greater than 0 -IN=n The indentation should be set to n. The value of n must be a positive integer greater than 0 filename Name of the file to be opened and read for input. A filename cannot begin with a dash. If no filename is provided, the program should read from the standard input. You are allowed to have multiple-LL and -IN flag arguments. If you do, the last one specified is used. So, for example, providing the command line arguments "-LL5-LL=20-LL=100" results in a line length of 100. The following error cases must be checked and handled: Error case How it is handled More than one filename provided Print "TOO MANY FILENAMES" and stop Unable to open file Print "UNABLE TO OPEN FILE filename" and stop Unrecognized flag argument (a flag argument Print "UNRECOGNIZED FLAG flag", and stop is an argument that begins with a dash) -LL or -IN flag does not have = after LL or IN Print "MISSING = SIGN flag" and stop -LL=n or -IN=n and n is not a positive integer greater than 0 Print "VALUE NOT INTEGER > O flag" and stop The program is instructed as to which options it should use by way of command line arguments. Command line argument Meaning -LL:n The output line length should be set to n. The value of n must be a positive integer greater than 0 -IN=n The indentation should be set to n. The value of n must be a positive integer greater than 0 filename Name of the file to be opened and read for input. A filename cannot begin with a dash. If no filename is provided, the program should read from the standard input. You are allowed to have multiple-LL and -IN flag arguments. If you do, the last one specified is used. So, for example, providing the command line arguments "-LL5-LL=20-LL=100" results in a line length of 100. The following error cases must be checked and handled: Error case How it is handled More than one filename provided Print "TOO MANY FILENAMES" and stop Unable to open file Print "UNABLE TO OPEN FILE filename" and stop Unrecognized flag argument (a flag argument Print "UNRECOGNIZED FLAG flag", and stop is an argument that begins with a dash) -LL or -IN flag does not have = after LL or IN Print "MISSING = SIGN flag" and stop -LL=n or -IN=n and n is not a positive integer greater than 0 Print "VALUE NOT INTEGER > O flag" and stopStep 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