In a file processing application, what is the primary difference between 'wb' and 'w' file modes?
A'wb' opens in binary mode while 'w' opens in text mode
B'w' is faster than 'wb'
C'wb' allows reading while 'w' does not
DThere is no difference in modern C compilers
Correct Answer:
A. 'wb' opens in binary mode while 'w' opens in text mode
EXPLANATION
'w' opens file in text mode (converts line endings), while 'wb' opens in binary mode (no conversion). This matters when handling platform-specific line endings (\r\n vs \n).
Which function is used to check if the end-of-file (EOF) has been reached in C file handling?
Afeof(fp)
Beof(fp)
Ciseof(fp)
Dcheckeof(fp)
Correct Answer:
A. feof(fp)
EXPLANATION
feof() is the standard C library function that returns non-zero if EOF has been reached on the given file stream. Other options are not valid C functions.
What does the 'w+' mode do when opening a file with fopen()?
AOpens file for reading and writing, creates if doesn't exist
BOpens file for writing only, appends data at end
COpens file for reading only
DOpens file in binary write mode
Correct Answer:
A. Opens file for reading and writing, creates if doesn't exist
EXPLANATION
'w+' mode opens a file for both reading and writing. If the file doesn't exist, it creates a new one. If it exists, it truncates the file to zero length.