What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
char line[3];
FILE *fp;
fp = fopen("newfile.txt", "r");
while (fgets(line, 3, fp))
fputs(line, stdout);
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char line[3];
FILE *fp;
fp = fopen("newfile.txt", "r");
while (fgets(line, 3, fp))
fputs(line, stdout);
return 0;
}A. Compilation error
B. Infinite loop
C. Segmentation fault
D. No.of lines present in file newfile
Answer: Option C

Join The Discussion