Input / Output

Q1:
Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    unsigned char;
    FILE *fp;
    fp=fopen('trial', 'r');
    if(!fp)
    {
        printf('Unable to open file');
        exit(1);
    }
    fclose(fp);
    return 0;
}

A Error: in unsigned char statement

B Error: unknown file pointer

C No error

D None of above

ANS:A - Error: in unsigned char statement

This program tries to open the file trial.txt in read mode. If file not exists or unable to read it prints "Unable to open file" and then terminate the program. If file exists, it simply close the file and then terminates the program.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.