HP C/iX Library Reference Manual (30026-90004)

Chapter 5 147
HP C/iX Library Function Descriptions
ferror
ferror
Tests whether the error indicator for a stream has been set.
Syntax
#include <stdio.h>
int ferror (FILE *
stream
);
Parameters
stream
A pointer to a file to be tested.
Return Values
0 Error indicator has not been set.
0 Error indicator has been set.
Description
The ferror function is intended to clarify ambiguous return values from standard I/O
functions.
The ferror function returns a nonzero value if the error indicator was set on the specified
stream
. It does not reset the indicator. You need to use the clearerr function to reset it.
Because I/O functions return EOF for end-of-file and error conditions, youcan use ferror()
and feof() to distinguish between them. Also, some systems support I/O functions that
take integer data instead of characters. For these functions, you need to use ferror() and
feof() to differentiate between valid data and the EOF flag.
See Also
fopen(), feof(), ANSI C 4.9.10.3, POSIX.1 8.1