FWRITE(3) Library Functions Manual FWRITE(3)

fwritebinary output

#include <stdio.h>

size_t fwrite(const void *ptr, size_t size, size_t nitems,
    FILE *stream);

The fwrite() function writes, from the array pointed to by ptr , up to nitems members whose size is specified by size , to the stream pointed to by stream . The file-position indicator for the stream (if defined) is advanced by the number of bytes successfully written. If an error occurs, the resulting value of the file-position indicator for the stream is indeterminate.

The and fields of the file will be marked for update between the successful execution of and the next successful completion of a call to or on the same stream or a call to or .

The fwrite() function returns the number of members successfully written, which may be less than nitems if a write error is encountered. If size or nitems is 0, fwrite() returns 0 and the state of the stream remains unchanged. Otherwise, if a write error occurs, the error indicator for the stream is set and errno is set to indicate the error.

Refer to fputc(3) .

None.

Because of possible differences in member length and byte ordering, files written using fwrite() are application-dependent, and possibly cannot be read using fread(3) by a different application or by the same application on a different processor.

None.

ferror(3) , fopen(3) , printf(3) , putc(3) , puts(3) , write(3) , <stdio.h> .

Derived from Issue 1 of the SVID.

February 1997 posix.fail