Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)
Guardian Native C Library Calls (f) fread(3)
NAME
fread - Reads input from a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
size_t fread(
void ∗∗pointer,
size_t size,
size_t num_items,
FILE ∗∗stream);
PARAMETERS
pointer Points to an array.
size Specifies the size of the variable type of the array pointed to by the pointer
parameter.
num_items Specifies the number of items of data.
stream Specifies the input output stream.
DESCRIPTION
The fread() function copies num_items of data of length size from the input stream into an array
beginning at the location pointed to by the pointer parameter.
The fread() function stops copying bytes if an End-of-File or error condition is encountered
while reading from the input specified by the stream parameter, or when the number of data items
specified by the num_items parameter have been copied. It leaves the file pointer of the stream
parameter, if defined, pointing to the byte following the last byte read, if there is one. The
fread() function does not change the contents of the stream parameter.
NOTES
If the stream parameter is invalid, the result of calling the fread() function is undefined.
RETURN VALUES
Upon successful completion, the fread() function returns the number of items actually
transferred. If the num_items parameter is negative or 0 (zero), no characters are transferred, and
a value of 0 (zero) is returned. If a read error occurs, the error indicator for the stream is set, and
errno is set to indicate the error.
ERRORS
The fread() function fails if:
• The stream parameter is not open for reading.
• The stream is unbuffered.
• The stream’s buffer needed to be flushed and the function call caused an underlying
write() or lseek() to be invoked and this underlying operation fails.
In addition, if any of the following conditions occur, the fread() function sets errno to the
corresponding value:
527192-005 Hewlett-Packard Company 2−55