Guardian C Library Calls Reference Manual

write (supplementary)
3-238 128833Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
write (supplementary)
The write function writes a specified number of bytes from a buffer to a file opened for
alternate I/O.
file_des
is the descriptor of a file opened for alternate I/O.
buf
points to the buffer to be written.
nbytes
specifies the number of bytes to write from the buffer.
Return Value
is the number of bytes written if the operation is successful, or -1 if an error occurs.
Example
This example reads two bytes from the array named buf and writes them to the file
$a.b.c:
#include <fcntlh>
int filedes;
short status;
short nbytes;
char buf[20];
filedes = open("$a.b.c", O_WRONLY|O_BINARY);
/* ... */
nbytes = 2;
status = write(filedes, buf, nbytes);
#include <fcntlh>
short write(int file_des, char *buf, short nbytes);