fread is a function that reads buffered binary input from a file.[1] 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)

The 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 size. 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

  1. ISO/IEC 9899:1999 specification (PDF). p. 301, § 7.19.8.1.

External links edit