HELPLIB.HLB  —  CRTL  close
    Closes the file associated with a file descriptor.

    Format

      #include  <unistd.h>

      int close  (int file_desc);

1  –  Argument

 file_desc

    A file descriptor.

2  –  Description

    The close function tries to write buffered data by using an
    implicit call to fflush. If the write fails (because the disk
    is full or the user's quota was exceeded, for example), close
    continues executing. It closes the OpenVMS channel, deallocates
    any buffers, and releases the memory associated with the file
    descriptor (or FILE pointer). Any buffered data is lost, and the
    file descriptor (or FILE pointer) no longer refers to the file.

    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.

3  –  Return Values

    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).

4  –  Example

        #include <unistd.h>

        int fd;
           .
           .
           .
        fd = open ("student.dat", 1);
           .
           .
           .
        close(fd);
Close Help