Entrance Exams
Govt. Exams
fgetc() is a function that reads a character from a file, while getc() is a macro. Both serve the same purpose but getc() may be faster due to macro expansion.
feof() returns true (non-zero) if the end-of-file indicator is set for the given file stream, otherwise it returns 0.
fseek() is used to move the file pointer to a specific position in the file. It takes three arguments: file pointer, offset, and origin.
ftell() returns the current position of the file pointer in bytes from the beginning of the file.
fprintf() writes formatted data to a file, similar to printf() but with a file pointer as the first argument.
fgets() reads a string from a file until a newline character or end of file is encountered. It takes three arguments: buffer, size, and file pointer.
"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.
fopen() is the standard C library function used to open a file. It takes two arguments: filename and mode.