Fclose Fflush flush or close a file #include <stdio.h> fclose FILE *fp fflush FILE *fp Description Fflush causes a buffer associated with the file pointer "fp" to be cleared by writing out to the file; of course, only if the file was opened for write or update. It is not normally ncesasary to call fflush, but it can be useful when, for example, normal output is to "stdout", and it is wished to send something to "stderr" which is unbuffered. If fflush were not used and "stdout" referred to the terminal, the "stderr" message will appear before large chunks of the "stdout" message even though the latter was written first. Fclose call fflush to clear out the buffer associated with "fp", closes the file, and frees the buffer for use by another fopen call. The exit() system call and normal termination of a program causes fclose to be called for each open file. See Also System call close(), fopen(), setbuf(). Diagnostics EOF is returned if "fp" does not refer to an output file or there is an error writing to the file.