Closes the file associated with a file descriptor.
#include <unistd.h> int close (int file_desc);
If your program needs to recover from errors when flushing buffered data, it should make an explicit call to fsync (or fflush) before calling close.
| 0 | Indicates that the file is properly closed. |
| -1 | Indicates that the file descriptor is undefined or an error occurred while the file was being closed (for example, if the buffered data cannot be written out). |
#include <unistd.h>
int fd;
.
.
.
fd = open ("student.dat", 1);
.
.
.
close(fd);