Closes a file.
int _close( int fd );
File descriptor referring to the open file.
_close returns 0 if the file was successfully closed. A return value of -1 indicates an error.
_close function closes the file associated with
The file descriptor and the underlying OS file handle are closed. Thus, it isn't necessary to call
CloseHandle if the file was originally opened using the Win32 function
CreateFile and converted to a file descriptor using
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
By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.
|Routine||Required header||Optional header|
For more compatibility information, see Compatibility.
See the example for
Submit and view feedback for