Guardian C Library Calls Reference Manual
ferror
3-40 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
ferror
The ferror function checks the error indicator of a file opened for ANSI I/O.
stream
denotes a file opened for ANSI I/O.
Return Value
is nonzero if an error occurred when reading or writing the file; otherwise, ferror
returns a zero.
Usage Guidelines
•
The ferror function might be implemented as a macro in a future release.
•
The error indicator remains set until one of the following events occurs:
•
The file is closed.
•
You call the clearerr function, which specifically clears the error indicator.
•
You call the fseek or edfseek function.
Example
This example checks the error indicator for the file $a.b.c:
#include <stdioh>
int status;
FILE *fp;
fp = fopen("$a.b.c", "r+");
/* ... */
status = ferror(fp);
if(status != 0)
printf("An error occurred reading or writing the file.");
#include <stdioh>
int ferror(FILE *stream);