Question: Using C++ Write the unix cat program. For each filename on the command line, open that file, read its contents, and write it to stdout.

Using C++

Write the unix cat program.

For each filename on the command line, open that file, read its contents, and write it to stdout.

Hint:

int main(int argc, char **argv)

{

for (int i=1; i

{

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

/*

TODO: more stuff. Maybe use fread() or fgets()

Ex. char buf[1024]; int r=fread(buf,1,sizeof(buf),f);

*/

fclose(f);

}

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!