Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-69
fwrite
fwrite
The fwrite function writes contiguous blocks of data to a file opened for ANSI I/O.
first_block
points to the first block of data to be written.
block_size
specifies the size (in bytes) of each block to be written.
block_count
specifies the number of blocks to be written.
stream
denotes a file opened for ANSI I/O.
Return Value
is the number of blocks written if the operation is successful; otherwise, fwrite
returns the value zero. If the value returned is less than you expected, use the ferror
and feof functions to determine the cause.
Example
In this example, the fwrite function writes one block of data from the array named block
to $a.b.c:
#include <stdioh>
FILE *fp;
int block[100];
int status;
fp = fopen("$a.b.c", "w");
/* ... */
status = fwrite((void *)block, sizeof block, 1, fp);
#include <stdioh>
size_t fwrite(const void *first_block, size_t block_size,
size_t block_count, FILE *stream);