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); (Compatability)
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.
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 Chapter 5.
Return Values
x | The number of bytes
written. |
-1 | Indicates
errors, including undefined file descriptors, illegal buffer
addresses, and physical I/O errors. |
Previous Page | Next Page | Table of Contents | Index