FWRITE - write "items" to a file.

(ANSI Standard)

Usage:

#include <stdio.h>
ret = fwrite( ptr, size, nitems, f );

Where:

const void *ptr;
points to an area holding data to be written.
size_t size;
is the size of one of the items being written out.
size_t nitems;
is the maximum number of items to be written.
FILE *f;
is the file to which the items should be written.
size_t ret;
is the number of items actually written. This will be equal to "nitems" unless an error occurs during the writing process.

Description:

"fwrite" writes a number of items to the file "f". These items may be characters, integers, structures, and so on. In order to use "fwrite", the file should have been opened with one of the "b" options of "fopen".

If you have a stream open for updating and you want to switch from reading to writing or vice versa, you must first do an "fseek" (or a "rewind"). The exception is that if you have been reading and have reached end-of-file, you can switch immediately to writing.

See Also:

expl c lib fread

expl c lib feof

expl c lib ferror

expl c lib fseek

expl c lib ftell

Copyright © 1996, Thinkage Ltd.