fread
—read array elements from a file#include <stdio.h> size_t fread(void *buf, size_t size, size_t count, FILE *fp); #include <stdio.h> size_t _fread_r(struct _reent *ptr, void *buf, size_t size, size_t count, FILE *fp);
Description
fread
attempts to copy, from the file or stream identified by
fp, count elements (each of size size) into memory,
starting at buf. fread
may copy fewer elements than
count if an error, or end of file, intervenes.
fread
also advances the file position indicator (if any) for
fp by the number of characters actually read.
_fread_r
is simply the reentrant version of fread
that
takes an additional reentrant structure pointer argument: ptr.
Returns
The result of fread
is the number of elements it succeeded in
reading.
Portability
ANSI C requires fread
.
Supporting OS subroutines required: close
, fstat
, isatty
,
lseek
, read
, sbrk
, write
.