Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would you implement this algorithm into C++? Using : int main(int argc, char* argv[ ]) The program is instructed as to which options it

How would you implement this algorithm into C++?

Using :

int main(int argc, char* argv[ ])

image text in transcribed

The program is instructed as to which options it should use by way of command line arguments. Command line argument Meaning The output line length should be set to n. The value of n must be a positive integer greater than 0 -LL=n -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 "-LL=5 -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 Unable to open file Print "TOO MANY FILENAMES" and stop Print "UNABLE TO OPEN FILE filename" and stop - Print "UNRECOGNIZED FLAG flag", and stop Unrecognized flag argument (a flag argument is an argument that begins with a dash) -LL or -IN flag does not have = after LL or IN S -LL-n or -IN=n and n is not a positive integer greater than 0 Print "MISSING = SIGN flag" and stop Print "VALUE NOT INTEGER > O flag" and stop - A

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions