FREAD - read "items" from a file.

(ANSI Standard)

Usage:

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

Where:

void *ptr;
points to an array in which to store the items being read.
size_t size;
is the size of one of the items being read in.
size_t nitems;
is the number of items to be read.
FILE *f;
is the file from which the items should be read.
size_t ret;
is the number of items actually read. This will be equal to "nitems" unless an error or end of file occurs during the read process.

Description:

"fread" reads a number of items from the file pointed to by "f".

If "f" is "stdin" and the standard output is line-buffered, any partial output line will be flushed before the reading takes place.

"fread" cannot check for overflow in the receiving area of memory. Thus the memory pointed to by "ptr" must be large enough to hold the number of items being read.

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 fwrite

expl c lib feof

expl c lib ferror

Copyright © 1996, Thinkage Ltd.