fread is a function that reads buffered binary input from a file. It is included from the stdio.h header file in the standard C library.
size_t fread (void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream)
fread function copies
nmemb items of data of size
size from the named input
stream into an array pointed to by
ptr. An item of data is a sequence of bytes (not necessarily terminated by a null byte) of length
fread stops appending bytes when
nmemb items have been read, end of file has been reached, or an error has occurred. Upon returning,
fread sets the file pointer in the stream pointing to the byte past the last byte that has been read. The contents of
stream remain unchanged. The
fread function returns the number of items actually read. If
nmemb is zero, no action is taken and the function will return 0.
References[edit | edit source]
- ISO/IEC 9899:1999 specification. p. 301, § 22.214.171.124. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf.