¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
Exportar (0) Imprimir
Expandir todo
div
eof
Expandir Minimizar
Importante Es posible que este documento no represente los procedimientos recomendados para el desarrollo actual. Puede que los vínculos a las descargas y otros recursos ya no sean válidos. Encontrará aquí la versión que se recomienda en la actualidad.

fclose, _fcloseall

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


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

stream

Pointer to FILE structure.

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. If stream is NULL, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, fclose sets errno to EINVAL and returns EOF. It is recommended that the stream pointer always be checked prior to calling this function.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, error codes.

The _fcloseall function 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.

Note: When these functions are used to close a stream, the underlying file descriptor and OS file handle (or socket) are closed, as well as the stream. Thus, if the file was originally opened as a file handle or file descriptor and is closed with fclose, do not also call _close to close the file descriptor; do not call the Win32 function CloseHandle to close the file handle; and do not call closesocket to also close the socket.

fclose and _fcloseall include code to protect against interference from other threads. For non-locking version of a fclose, see _fclose_nolock.

Function

Required header

fclose

<stdio.h>

_fcloseall

<stdio.h>

For additional compatibility information, see Compatibility in the Introduction.

See the example for fopen.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft