Below is a basic implementation of the Linux command cat Thi
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 = fp
Solution
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
