Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Update the program by removing the system function , implement a quit function and have the program wait for the user to enter

Using C++

Update the program by removing the system function, implement a quit function and have the program wait for the user to enter the first command and second one rather than having the program ask for them. Make sure all the functions work correctly in linux.

#include #include #include

using namespace std;

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

char choice; //Declare a variable

std::string line1, line2, command;

std::string line;

do

{

cout << "enter first string ";

getline(std::cin, line1); //get the first input from user

cout << "enter second string ";

getline(std::cin, line2); // get the second input from the user

string toCompare = "quit"; // declare a quit statement

if (line1 == "quit" || line2 == "quit") // conditonal statemet {

break; // to break if quit stement is executed

}

command = line1 + "|" + line2;

const char *finalCommand = command.c_str(); //system takes only const char *, c_str is used for conversion

system(finalCommand);

std::cout << line << std::endl;

cout << "do you want to do it again ? Y/N "; // repeat statement

cin >> choice;

} while (choice == 'Y');

}

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

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago