close a file
#include <stdio.h> int fclose( FILE *fp );
The fclose() function closes the file fp. If there's any unwritten buffered data for the file, it's written out before the file is closed. Any unread buffered data is discarded. If the associated buffer was automatically allocated, it's deallocated.
#include <stdio.h> void main() { FILE *fp; fp = fopen( "stdio.h", "r" ); if( fp != NULL ) { fclose( fp ); } }
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
errno, fcloseall(), fdopen(), fopen(), freopen(), _fsopen()