fclose
The close function close a file in the file system that has been previously opened by the fopen function.
The fclose function requires only one argument, a pointer to the FILE structure representing the file to be closed. The fclose function returns an integer value, which is zero in case of success.
The following is an example of use of the fopen function:
#include <stdio.h> int main() { FILE *file; file = fopen("myfile", "r"); // ... // read from my file // ... fclose(file); return 0; }
Note: In normal circumstances, every call to fopen should correspond to a call to fclose. However, when a program ends all open files are closed automatically by the operating system, so it is not necessary to call fclose if this is the last step of a program.
Article created on 2008-08-19 21:51:47
Post a comment