Home » C Programming » Input & Output » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    char line[25];
    FILE *fp;
    fp = fopen("file.txt", "r");
    while (fgets(line, 25, fp))
    fputs(line, stdout);
    return 0;
    }
    1. No.of lines present in file.txt
    2. Infinite loop
    3. Compilation error
    4. Segmentation fault
    5. None of these
Correct Option: D

Segmentation fault



Your comments will be displayed only after manual approval.