Question: Convert code to C++ Hi I need you to convert C to C++. I'm testing .sh file. Screenshot is below and is perfectly working on

Convert code to C++

Hi I need you to convert C to C++. I'm testing .sh file. Screenshot is below and is perfectly working on C. please convert C++.

/////First file: wcat.c

#include

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

if(argc == 1){

return 0;

}

//implementing Wcat

for(int i =1;i

char totalBuf[100];

FILE *myFile = fopen(argv[i], "r");

if (myFile == NULL) {

printf("wcat: cannot open file ");

return 1;

}

while(fgets(totalBuf, 100, myFile) != NULL){

printf("%s",totalBuf);

}

fclose(myFile);

}

return 0;

}

////////Second file: wgrep.c

#include

#include

#include

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

if(argc ==1){

printf("wgrep: searchterm [file ...] ");

return 1;

}

else if(argc ==2){

size_t len = 0;

ssize_t linesize=0;

char* output = NULL;

int counter =1;

while((linesize = getline(&output, &len, stdin)) != -1){

if(strstr(output, argv[1])){

printf( "%s",output);

counter++;

}

}

return 0;

}

else{

for(int i =2;i

FILE *file = fopen(argv[i], "r");

if (file == NULL){

printf("wgrep: cannot open file ");

return 1;

}

size_t len = 0;

ssize_t linesize=0;

char* output = NULL;

int counter =1;

while((linesize = getline(&output, &len, file)) != -1){

if(strstr(output, argv[1])){

printf( "%s",output);

}

counter++;

}

fclose(file);

free(output);

output = NULL;

len = 0;

}

}

return 0;

}Convert code to C++ Hi I need you to convert C to

tonmoy@f0-79-60-29-2e-d8 wgrep % cd /Users/tonmoy/Downloads/projecto-tests/wcat tonmoy@f0-79-60-29-2e-d8 wcat % ls atest.txt test-wcat.sh tests-out wcat.c test tests wcat tonmoy@f0-79-60-29-2e-d8_wcat % wcc wcat.c -o wcat zsh: command not found: WCC tonmoyof0-79-60-29-2e-d8 wcat % ls atest.txt test-wcat.sh tests-out wcat.c test tests wcat tonmoycf0-79-60-29-2e-d8_wcat % gcc wcat.co wcat tonmoy@f0-79-60-29-2e-d8 wcat % ./test-wcat.sh Te[32mtest 1: passed e[ Om Te[32mtest 2: passed\e[Om Te[32mtest 3: passedle[Om Te[32mtest 4: passed\e[Om Te[32mtest 5: passed\e[ Om Te[32mtest 6: passed\e[Om Te[32mtest 7: passed e[Om tonmoy@f0-79-60-29-2e-d8 wcat % cd /Users/tonmoy/Downloads/projecto-tests/wgrep tonmoy@f0-79-60-29-2e-d8 wgrep % ls bar.txt test-wgrep.sh tests-out wgrep test tests wcat wgrep.c tonmoy@f0-79-60-29-2e-d8 wgrep % gcc wgrep.c -o wgrep tonmoy@f0-79-60-29-2e-d8 wgrep % ./test-wgrep.sh, Te[32mtest 1: passed e[ Om Te[32mtest 2: passed\e[ Om Te[32mtest 3: passedle[Om Te[32mtest 4: passed\e[Om Te[32mtest 5: passed\e[Om Te[32mtest 6: passed e[ Om Te[32mtest 7: passed e[ Om tonmoy@f0-79-60-29-2e-d8 wgrep %

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!