LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

fread

fread

size_t fread (void *buffer, size_t elementSize, size_t numberOfElements, FILE *stream);

Purpose

Reads a block of data from the specified input stream then stores it in the specified buffer. The function returns the number of elements successfully read and advances the file position indicator by the number of bytes read, that is (number_ofElements*elementSize).

Note Note  If you have opened the file for read/write, you cannot call fread after a call to fwrite or any of the other file output functions without an intervening call to fflush.

Parameters

Input
Name Type Description
elementSize size_t Specifies the size in bytes of each element to be read.
numberOfElements size_t Specifies the number of elements to be read. If a read error occurs or end-of-file is reached, the number of elements actually read can be less than the number specified in this parameter.
stream FILE * Specifies the input stream from which data will be read.
Output
Name Type Description
buffer void * Contains the address of a buffer that receives the data read from the specified input stream.

Return Value

Name Type Description
elementsRead size_t Contains the number of elements successfully read. If an error occurs, fread returns 0 and sets errno to a nonzero value.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?