Home » C Programming » Error Handling » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    FILE *fp;
    char ch;
    int num = 0;
    fp = fopen("file1.txt", "r");
    while (!feof(fp))
    {
    ch = getc(fp);
    putc(ch, stdout);
    }
    }
    1. Prints to the screen content of file1.txt completely
    2. Prints to the screen some contents of newfile1.txt
    3. Compilation error
    4. Segmentation fault
    5. None of these
Correct Option: D

Segmentation fault



Your comments will be displayed only after manual approval.