fwrite [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
fwrite
Writes data items to an open stream.
Syntax
#include <stdio.h>
size_t fwrite (const void *ptr, size_t size,
size_t nitems, FILE *stream);
Parameters
ptr A pointer to a buffer that holds the data to be written to
the open stream. The type of the buffer is determined by
the type of the data being written.
size The size of each data item, in bytes.
nitems The number of data items to write.
stream A pointer to an open stream.
Return Values
>0 The number of items actually written.
Description
The fwrite function is the output analog of the fread function. It
writes a buffer pointed to by the ptr argument to the stream pointed to
by the stream argument. The number of characters written is equal to the
size argument times the nitems argument.
The file position indicator (if defined) is advanced by the number of
characters successfully written.
The fwrite function returns the number of elements actually written.
This is equal to the number requested unless fwrite() encounters an
error. In this case, the file position indicator for the stream is
indeterminate.
Examples
Refer to the examples located in the fread function description.
See Also
fread(), ANSI C 4.9.8.2, POSIX.1 8.1
MPE/iX 5.0 Documentation