Question: Convert C to C++ I need these 4 C file code convert to C++. Please Convert it to C++ //////first C file: Wunzip.c #include int

Convert C to C++

I need these 4 C file code convert to C++. Please Convert it to C++

//////first C file: Wunzip.c

#include

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

if(argc ==1){

printf("wunzip: file1 [file2 ...] ");

return 1;

}

else{

for(int i =1; i< argc;i++){

int num=-1;

int numout=-1;

int c;

int c1;

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

if(file == NULL){

printf("Cannot Open File ");

return 1;

}

else{

while(numout != 0){

numout = fread(&num, sizeof(int), 1, file);

c = fread(&c1, sizeof(char), 1, file);

if(c!= 0){

for(int a =0;a< num;a++){

printf("%c",c1);

}}

}

}

fclose(file);

}

return 0;

}

}

/// Second C 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< argc;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;

}

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!