fwrite

Syntax

int fwrite(void* buffer, int size, int numitems, void* file)

Arguments

buffer
A pointer to the data buffer containing the data you want to write to the file.
size
The size of the data blocks you want to write out (eg if writing 32-bit integers, you might set this to 4 bytes).
numitems
The number of blocks of data you want to write to the file (eg number of integers you want to write to the file in a row).
file
The pointer/handle to the already opened file you want to write to.

Return

Returns the number of items that were successfully written to the file.

Description

Writes data to a previously opened file or stream.

Comments

The size and numitems parameters can be confusing - it's often easier to set the size parameter to the number of bytes you want to write to the file, and keep the numitems parameter set to 1.

Also see

fopen, fread, fseek, fsetpos, fclose