VMS Help  —  CRTL  write
    Writes a specified number of bytes from a buffer to a file.

    Format

      #include  <unistd.h>

      ssize_t write  (int file_desc, void *buffer, size_t nbytes);

                     (ISO POSIX-1)

      int write  (int file_desc, void *buffer, int nbytes);

                 (Compatibility)

1  –  Arguments

 file_desc

    A file descriptor that refers to a file currently opened for
    writing or updating.

 buffer

    The address of contiguous storage from which the output data is
    taken.

 nbytes

    The maximum number of bytes involved in the write operation.

2  –  Description

    If the write is to an RMS record file and the buffer contains
    embedded new-line characters, more than one record may be written
    to the file. Even if there are no embedded new-line characters,
    if nbytes is greater than the maximum record size for the file,
    more than one record will be written to the file. The write
    function always generates at least one record.

    If the write is to a mailbox and the third argument, nbytes,
    specifies a length of 0, an end-of-file message is written to
    the mailbox. This occurs for mailboxes created by the application
    using SYS$CREMBX, but not for mailboxes created to implement
    POSIX pipes. For more information see the "Subprocess Functions"
    chapter of the VSI C RTL Reference Manual.

3  –  Return Values

    x                  The number of bytes written.
    -1                 Indicates errors, including undefined file
                       descriptors, illegal buffer addresses, and
                       physical I/O errors.
Close Help