Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

! Write a C++ program that loops through all of the command line arguments that are passed to the program, beginning with the argument after

! Write a C++ program that loops through all of the command line arguments that are passed to the program, beginning with the argument after the program name. !

The first command line argument must be the string small, medium or large. ! If the first command line argument is missing, your program should print MISSING SIZE and stop. !

If the first command line argument is not the string small, medium or large, then your program should print the argument followed by a space and the message NOT A VALID SIZE, then should stop. !

For each command line argument after the first argument, your program should determine the length of the argument. If its length is greater than or equal to the size specified by the first command line argument (we define small to mean size 5, medium to mean size 10, and large to mean size 20), then the program should print the argument. !

Note that it is possible, and valid, for there to be no command line arguments after the first command line argument. !

Reminder: the first entry in the array of command line arguments, at the [0] position in the array, is the name of the program. We do not look at or use that value in this assignment. !

Example: !

> ./program MISSING SIZE

> ./program foo NOT A VALID SIZE

> ./program small

> ./program small foo blurf nonsensical gobbledegookgobbledegook blurf nonsensical gobbledegookgobbledegook

> ./program medium foo blurf nonsensical gobbledegookgobbledegook nonsensical gobbledegookgobbledegook

> ./program large foo blurf nonsensical gobbledegookgobbledegook gobbledegookgobbledegook !

(with explanations please, this is the first time I am learning c++)

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

Students also viewed these Databases questions