Question
Using C++ modified the program bellow by correcting std::istream::getline, implementing wordsToFind parameter and used the other parameters listed Description For this assignment, you will be
Using C++ modified the program bellow by correcting std::istream::getline, implementing wordsToFind parameter and used the other parameters listed
Description
For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is quit, the program should immediately exit. If quit is not found, each of these lines of input will be treated as a command line to be executed. These two commands should be executed as if the user had typed command1 | command2 at the shell prompt, meaning that the standard output of the first command gets redirected into the standard input of the second command. (It should be noted that using cin >> will not grab a whole line; you will need to use another function instead.) You will need to be able to split the text entered by the user into the different command line arguments that comprise it. I do not care how this is accomplished, but some possibilities are to use the C function strtok, or a C++ istringstream object. You do not need to worry about escaping special characters when splitting the string for the purposes of this assignment; the split can be performed based on spaces alone.After these commands have both finished executing, your program should prompt for another pair of input commands to run, repeating the process over and over again until the user gives quit as input.
#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
char string1[127], string2[127];
int flag = 0;
cout << "enter first string";
std::cin.getline(string1,127)
cout << "enter second string";
std::cin.getline(string2,127)
int choice;
do
{
for (int i = 0; i <= 120; i++)
{
int wordstofind;
if (string1 == wordsToFind[i] != string::quit)
{
ifstream the_file(argv[1]);
if (!the_file.is_open())
cout << "Could not open file ";
else {
char x;
while (the_file.get(x))
cout << x;
}
}
}
cout << "do you want to do it again ? Y/N ";
cin >> choice;
}
while (choice == 'Y');
return 0;
}
Step 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