|
|
Files - Closing |
|
int fclose (FILE* fp)
Break the connection between the file pointer and the file. Contents are flushed and file is closed.
When writing to a file output does not immediately go to the file. All modern operating systems will intercept the data and write it out in the most efficient way possible. Flushing is the act of moving the data from the intermediate storage to the physical medium.
Closing a file or exiting the program causes an automatic flush.
Each operating system has a limit to the number of allowed open files. It is a good idea to close them when they are no longer needed.