Function close

Top 

Declaration:

int close(long handle);

Description

Closes a file.

The close function closes the file associated with handle (the file handle obtained from a call to creat, creatnew, creattemp, dup, dup2, ).

It does not write the Ctrl-Z character to the end of the file. If you want to terminate the file with Ctrl-Z, you must explicitly output it.

Returned value

Upon successful completion, close returns 0. On error (if it fails because handle is not the handle of a valid, open file), close returns -1 and the errno global variable is set to

EBADF        Bad file number