C - File Operation : Close a File
When we have finished reading from the file, we need to close it. This is done using the function fclose() through the statement.
fclose ( fp ) ;
Once we close the file we can no longer read from it using getc() unless we reopen the file.
Declaration of fclose( ) Function
int fclose(FILE * fptr);
File mode | Description |
r | Open a text file for reading |
w | Create a text file for writing, if it exists, it is overwritten |
a | Open a text file and append text to the end of the file |
rb | Open a binary file for reading |
wb | Create a binary file for writing, if it exists, it is overwritten |
ab | Open a binary file and append data to the end of the file |