File Handling


1
Question 1
Which of the following true about FILE *fp
A
FILE is a keyword in C for representing files and fp is a variable of FILE type.
B
FILE is a structure and fp is a pointer to the structure of FILE type
C
FILE is a stream
D
FILE is a buffered stream
File Handling    
Discuss it


Question 1 Explanation: 
fp is a pointer of FILE type and FILE is a structure that store following information about opened file. 1
Question 2
When fopen() is not able to open a file, it returns
A
EOF
B
NULL
C
Runtime Error
D
Compiler Dependent
File Handling    
Discuss it


Question 2 Explanation: 
fopen() returns NULL if it is not able to open the given file due to any of the reasons like file not present, inappropriate permissions, etc.
Question 3
getc() returns EOF when
A
End of files is reached
B
When getc() fails to read a character
C
Both of the above
D
None of the above
File Handling    
Discuss it


Question 3 Explanation: 
Question 4
In fopen(), the open mode "wx" is sometimes preferred "w" because. 1) Use of wx is more efficient. 2) If w is used, old contents of file are erased and a new empty file is created. When wx is used, fopen() returns NULL if file already exists.
A
Only 1
B
Only 2
C
Both 1 and 2
D
Neither 1 nor 2
File Handling    
Discuss it


Question 5
fseek() should be preferred over rewind() mainly because
A
rewind() doesn't work for empty files
B
rewind() may fail for large files
C
In rewind, there is no way to check if the operations completed successfully
D
All of the above
File Handling    
Discuss it


Question 5 Explanation: 
There are 5 questions to complete.
1

Company Wise Coding Practice    Topic Wise Coding Practice