Update the code to only use C++ and remove any implementation of C . Finally add
ID: 3600634 • Letter: U
Question
Update the code to only use C++ and remove any implementation of C. Finally add a repeating loop into the program, that lets the user determine if they want to repeat the program
#include<iostream.h>
#include<conio.h>
using namespace std;
void main()
{
char string1[127], string2[127];
int flag = 0;
cout << "enter first string";
gets(string1);
cout << "enter second string";
gets(string2);
getline(string1, string2)
for (int i = 0; i <= 120; i++)
{
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;
}
}
}
}
Explanation / Answer
Please find my naswer.
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char const *argv[]){
char op = 'y';
while(op == 'y' || op == 'Y') {
string string1, string2;
cout << "enter first string";
getline(cin, string1);
cout << "enter second string";
getline(cin, string2);
for (int i = 0; i <= 120; i++)
{
if (string1 == wordsToFind[i])
{
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 cintunue (y/n) ? ";
cin>>op;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.