Question: Need to add a statement that prints out no flag when someone does not enter one of the argument commands while keeping the unrecognized flag

Need to add a statement that prints out no flag when someone does not enter one of the argument commands while keeping the unrecognized flag

if (argc == 2) {

cout << "Total Number of words: " << all << endl; cout << "Number of Type 1 names: " << type1 << endl; cout << "Number of Type 2 names: " << type2 << endl;

}

//Create string flag that equals the //2nd arguement value string flag = argv[2]; //If flag equals -all if (flag == "-all") { /* Print out the all the words, and type 1 and type 2 words */ cout << "Total Number of words: " << all << endl; cout << "Number of Type 1 names: " << type1 << endl; cout << "Number of Type 2 names: " << type2 << endl; }

//Else if flag is equal to command "-type1" else if (flag == "-type1") { //Print out type1 names cout << "Number of Type 1 names: " << type1 << endl; } //Else if flag is equal to command "type2" else if (flag == "-type2")

{ //Print out type2 names cout << "Number of Type 2 names: " << type2 << endl; }

//else statement prints out not recognized flag else { cout << "UNRECOGNIZED FLAG " << argv[2] << endl; }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!