fread -- Read Items

Format

#include <stdio.h>
size_t fread(void *buffer, size_t size, size_t count,
                FILE *stream);

Language Level: ANSI, POSIX, XPG4
fread reads up to count items of size length from the input stream and stores them in the given buffer. The position in the file increases by the number of bytes read.

Return Value
fread returns the number of full items successfully read, which can be less than count if an error occurs or if the end-of-file is met before reaching count. If size or count is 0, fread returns zero and the contents of the array and the state of the stream remain unchanged.

Use ferror and feof to distinguish between a read error and an end-of-file.

Example



feof -- Test End-of-File Indicator
ferror -- Test for Read/Write Errors
fopen -- Open Files
fwrite -- Write Items
read -- Read Into Buffer
<stdio.h>