Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

What is the difference between outsourcing and captive sourcing?

Answered: 1 week ago