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
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