Govt. Exams
Entrance Exams
fclose() terminates the file stream, flushes any buffered data to disk, and releases the file handle. It doesn't delete or clear the file.
"w+" opens file for reading and writing, truncating it if it exists, and creating it if it doesn't. "r+" requires file to exist. "a+" opens in append mode with read capability.
fopen() uses double quotes for string arguments in C. The first argument is filename and second is mode. Single quotes are for characters, not strings.
ftell() returns the current position (as a long integer) of the file pointer in the file. fseek() is used to change position, rewind() resets to beginning, and fgetpos() stores position in a structure.
The 'b' flag specifies binary mode, which prevents any translation of line endings or special characters.
The 'r' mode opens a file for reading only. The file must exist, otherwise fopen() returns NULL.
Opening a file in 'w' mode truncates the file to zero length if it exists, discarding all previous content.
"w" mode opens a file for writing. If the file exists, it truncates the file to zero length. If it doesn't exist, a new file is created.
fclose() is the standard function to close an opened file stream. It returns 0 on success and EOF on error.
'rb' mode opens a file for reading in binary format. Binary mode reads the exact bytes without any text conversion.