Compartir a través de


_close

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at _close.

Closes a file.

Syntax

int _close(   
   int fd   
);  

Parameters

fd
File descriptor referring to the open file.

Return Value

_close returns 0 if the file was successfully closed. A return value of –1 indicates an error.

Remarks

The _close function closes the file associated with fd.

The file descriptor and the underlying OS file handle are closed. Thus, it is not necessary to call CloseHandle if the file was originally opened using the Win32 function CreateFile and converted to a file descriptor using _open_osfhandle.

This function validates its parameters. If fd is a bad file descriptor, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, the functions returns -1 and errno is set to EBADF.

Requirements

Routine Required header Optional header
_close <io.h> <errno.h>

For more compatibility information, see Compatibility in the Introduction.

Example

See the example for _open.

See Also

Low-Level I/O
_chsize
_creat, _wcreat
_dup, _dup2
_open, _wopen
_unlink, _wunlink