ferror
raw OCR
Detects errors on stream.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
int ferror(FILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
terror is a macro that tests the given stream for a read or write error. If the stream's error indicator has been set, it remains set until clearerr or rewind is called, or until the stream is closed.
Return value
terror returns nonzero if an error was detected on the named stream.
See also
Example
#include <stdio.h>
int main(void)
{
FILE *stream;
/* open a file for writing */
stream = fopen("DUMMY.FIL", "w");
/* force an error condition by attempting to read */
(void) getc(stream);
if (ferror(stream)) { /* test for error on the stream */
/* display an error message */
printf("Error reading from DUMMY.FIL\n") ;
/* reset the error and EOF indicators */
clearerr(stream);
}
fclose(stream);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `terror` read as `ferror`
Stable link: /3.1/stdio.h/ferror/
· short form /3.1/ferror/