Everything

fwrite


Outputs data from a memory area to a stream input/output file.

[Format]

#include <stdio.h>

size_t fwrite (const void *ptr, size_t size, size_t n, FILE *fp);

[Parameters]

ptr Pointer to storage area storing data to be output

size Number of bytes in one member

n Number of members to be output

fp File pointer

[Return values]

Number of successfully output members

[Remarks]

The fwrite function outputs n members whose size is specified by size, from the storage area pointed to by ptr, to the stream input/output file indicated by file pointer fp. The file position indicator for the file is advanced by the number of bytes output.

The fwrite function returns the number of members successfully output, which is normally the same as the value of n. However, when an error occurs, the number of members successfully output so far is returned, and then the return value will be less than n.

When an error occurs, the file position indicator is not guaranteed.