7.19.5.1 The fclose function
Synopsis
#include <stdio.h>
int fclose(FILE *stream);
Description
A successful call to the fclose function causes the stream pointed to by stream to be flushed and the associated file to be closed. Any unwritten buffered data for the stream are delivered to the host environment to be written to the file; any unread buffered data are discarded. Whether or not the call succeeds, the stream is disassociated from the file and any buffer set by the setbuf or setvbuf function is disassociated from the stream (and deallocated if it was automatically allocated).
Returns
The fclose function returns zero if the stream was successfully closed, or EOF if any errors were detected.