© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

6. What is the disadvantages of the low-level file I/O?

Ans:

The disadvantage of Low-Level Disk I/O functions is that the programmer has to manage the buffers.

Ex 1: What is the output?

#include "stdio.h"
main( )
{
 FILE *fp ;
 char c ;
 fp = fopen ( "TRY.C" ,"r") ;
if ( fp == null )
{
            puts ( "Cannot open file" ) ;
            exit( ) ;
}
while ( ( c = getc ( fp ) ) != EOF )
putch ( c ) ;
fclose ( fp ) ;
}

Ans:

compile time error

Explanation:
 The null is undefined literal in c. So compiler give the error. If u give NULL it is run successfully.

Ex 2: What is the output?

#include<stdio.h>
main( )
{
FILE *fp ;
char str[80] ;
fp = fopen ( "TRY.C", "r" ) ;
while ( fgets ( str, 80, fp ) != EOF )
fputs ( str ) ;
fclose ( fp ) ;
}

Ans:

Compiler error.

Explanation:

The fputs() in the above program hava only one argument.The syntax of  the fputs() have two argument. So fputs() call don’t match with definition of that function.

SLogix Student Projects
bottom