ferror(3C)
_________________________________________________________________
ferror macro
Determine if an error occurred during I/O.
_________________________________________________________________
Calling Sequence
FILE *fp;
int errset;
errset = ferror(fp);
Description
Use the ferror macro to determine if an error occurred during
I/O. Since ferror is a macro, you will receive error messages if
you attempt to redeclare it or pass it to a function.
Returns
The ferror macro returns 1 upon error.
Related Functions
See also the perror function.
Example
The following program shows how to use the ferror macro.
#include <stdio.h>
FILE *fp, *fopen();
main() {
int ch;
fp = fopen("file", "w");
fscanf(fp, "%d", &ch);
if (ferror(fp))
printf("I/O error.")
return 0;
}
A call to the program test with an argument of 1 generates the
output
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
ferror(3C)
I/O error.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)