C Programming/POSIX Reference/unistd.h/write

The write system call writes data, in bytes as specified by the caller, from a buffer declared by the user in the program and then writes it into the file supplied by the calling process. In most modern operating system, a program that needs to write data to a file stored in a filesystem uses the Write system call. The file is identified by the file descriptor that is obtained from a previous call to open.

Write, thus, takes three arguments:
 * 1) The file descriptor of the file (fd).
 * 2) The buffer from where data is to be written into the file (buf).
 * 3) The number of bytes to be read from the buffer (nbytes).

POSIX usage
The write system call interface  is standardized by the POSIX specification. Data is written to a file by calling the write function. The function prototype is :

In above syntax,  is a. It is a signed data type defined in. operator produces an integer value which is of type size_t. The write function returns the number of bytes successfully written into the array, which may at times be less than the specified nbytes. It returns -1 if an error is encountered.

Errors encountered during operation
Listed below are some errors that could be encountered during writing to a file. The errors are macros listed in errno.h.