Below is a basic implementation of the Linux command \"cat\". This command is us
ID: 3794291 • Letter: B
Question
Below is a basic implementation of the Linux command "cat". This command is used to print the contents of a file on the console/terminal window. #include #include int main(int argc, char* argv[]) {FILE *fp; if(2 != argc) {priritf ("Usage: cat "); exit(1);} if ((fp = fopen(argv[1], "r")) == NULL) {fprintf (stderr, "Can't. open input file %s ", argv[1]); exit (1);} char buffer[256]; while (fgets(X, 256, fp) != NULL) fprintf(Y, "%s", buffer); fclose(Z); return 0;} Which one of the following replacements for X, Y and Z will result in correct execution? X = buffer, Y = fp, Z = stdout X = fp, Y = stdout, Z = buffer X = buffer, Y = stdin, Z = fp X = buffer, Y = fp, Z = fp X = buffer, Y = stdout, Z = fpExplanation / Answer
Ans: X = buffer, Y = stdout, Z = fp
X = represent the memory in which you want to read data
Y = represent where you want to display data
Z : file closing
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.