Writes into a given position within a file without changing the file pointer. This function is supported on OpenVMS Integrity servers and Alpha only. Format #include <unistd.h> ssize_t pwrite (int file_desc, const void *buffer, size_t nbytes, off_t offset);
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. offset The offset for the desired position inside the file.
2 – Description
The pwrite function performs the same action as write, except that it writes into a given position in the file without changing the file pointer. The first three arguments to pwrite are the same as for write, with the addition of a fourth argument offset for the desired position inside the file.
3 – Return Values
n The number of bytes written. -1 Upon failure, the file pointer remains unchanged and pwrite sets errno to one of the following values: o EINVAL - The offset argument is invalid. The value is negative. o ESPIPE - fildes is associated with a pipe or FIFO.