This documentation is archived and is not being maintained.

fclose, _fcloseall

Closes a stream (fclose) or closes all open streams (_fcloseall).

int fclose( 
   FILE *stream 
int _fcloseall( void );


Pointer to FILE structure.

Return Value

fclose returns 0 if the stream is successfully closed. _fcloseall returns the total number of streams closed. Both functions return EOF to indicate an error.


The fclose function closes stream. _fcloseall closes all open streams except stdin, stdout, stderr (and, in MS-DOS, _stdaux and _stdprn). It also closes and deletes any temporary files created by tmpfile. In both functions, all buffers associated with the stream are flushed prior to closing. System-allocated buffers are released when the stream is closed. Buffers assigned by the user with setbuf and setvbuf are not automatically released.


Function Required header Compatibility
fclose <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
_fcloseall <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


See the example for fopen.

See Also

Stream I/O Routines | _close | _fdopen | fflush | fopen | freopen | Run-Time Routines and .NET Framework Equivalents