Syntax
#include <stdio.h> int _fcloseall(void);Description
_fcloseall flushes all buffers associated with the streams before closing them. When it closes streams, it releases the buffers that the system reserved, but does not release user-allocated buffers.
This example opens a file john for reading as a data stream, and then closes the file. It closes all other streams except stdin, stdout, and stderr.
#include <stdio.h> #define OUTFILE "temp.out" int main(void) { FILE *stream; int numclosed; stream = fopen(OUTFILE, "w"); numclosed = _fcloseall(); printf("Number of files closed = %d\n", numclosed); remove(OUTFILE); return 0; /**************************************************************************** The output should be: Number of files closed = 1 ****************************************************************************/ }Related Information