Question: C++ help. Please these 2 C files code to c++. I need them in c++. //////Third C file: wcat.c #include int main( int argc, char

C++ help.

Please these 2 C files code to c++. I need them in c++.

//////Third C 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;

}

/////////Fourth C file: wzip.c

#include

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

char currentC;

char previousC;

int count = 1;

int stop =1;

if(argc == 1 ){

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

return 1;

}

else{

for(int i =1;i

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

if(file == NULL){

printf("wzip: cannot open file ");

return 1;

}

else{

previousC = fgetc(file);

// FILE *file1 = fopen("newfile","w") ;

while((currentC = fgetc(file)) != EOF){

if(previousC == currentC){

count++;

}

else{

fwrite(&count, 4, 1, stdout);

fwrite(&previousC, sizeof(char), 1, stdout);

previousC = currentC;

count =1;

}

}

fwrite(&count, 4, 1, stdout);

fwrite(&previousC, sizeof(char), 1, stdout);

}

fclose(file);

}

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!