Entrance Exams
Govt. Exams
fgets() reads up to and including the newline character. For an empty line, it reads just the newline character into the buffer.
fscanf() reads formatted data from a file stream, functioning as the file equivalent of scanf().
In text mode, platform-specific line endings (\r\n on Windows, \n on Unix) are translated. Binary mode reads bytes as-is without translation.
fseek(fp, 0, SEEK_END) positions the file pointer at the end of file. SEEK_END is the third constant in <stdio.h>.
ftell() returns the current position of the file pointer as a long integer offset from the beginning of the file.
fopen() returns NULL pointer on failure. Checking 'fp == NULL' or '!fp' is the correct approach. Option C uses explicit NULL check which is clearer.
clearerr() clears both the EOF indicator and the error flag associated with a stream.
The 'r+' mode opens a file for both reading and writing without truncating it. The file must exist.
ferror() returns a non-zero value if an error flag is set for the stream, otherwise returns 0.
fgets() reads a string from file including whitespace until newline or EOF is encountered or max length is reached.