MicrOS
fread.c File Reference
#include "../stdio.h"

Functions

size_t fread (void *ptr, size_t size, size_t count, FILE *stream)
 Read block of data from stream. More...
 

Function Documentation

◆ fread()

size_t fread ( void *  ptr,
size_t  size,
size_t  count,
FILE stream 
)

Read block of data from stream.

Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr. The position indicator of the stream is advanced by the total amount of bytes read.

Parameters
ptrPointer to a block of memory with a size of at least (size*count) bytes, converted to a void*.
sizeSize, in bytes, of each element to be read.
countNumber of elements, each one with a size of size bytes.
streamPointer to a FILE object that identifies the stream to be closed.
Returns
The total number of elements successfully read is returned. If this number differs from the count parameter, either a reading error occurred or the end-of-file was reached while reading. In both cases, the proper indicator is set.