Home / C Programming / Input / Output :: Discussion

Discussion :: Input / Output

  1. Point out the error in the program?

     #include 
     /* Assume there is a file called 'file.c' in c:\tc directory. */
     int main()
     {    
           FILE *fp;      
           fp=fopen("c:\tc\file.c", "r");         
           if(!fp)   
              printf("Unable to open file.");          
           fclose(fp);   
           return 0; 
    }
    

  2. A.

    No error, No output.

    B.

    Program crashes at run time.

    C.

    Output: Unable to open file.

    D.

    None of above

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    The path of file name must be given as "c:\\tc\file.c"


Be The First To Comment