On this page
ferror
Prev: feof | Up: stdio.h | Next: perror
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — ferror
Tags: #public #prog #c #stdlib #stdio #tier/standard
Include
#include <stdio.h>
Signature & Overview
int ferror(FILE *stream);
Returns non-zero if the error indicator is set on stream.
Notes & Pitfalls
- Distinguishes I/O errors from clean EOF: Check
ferror(f)afterfgets()returnsNULLorfread()returns a short count.
Example
#include <assert.h>
#include <stdio.h>
int main(void) {
FILE *f = tmpfile();
assert(ferror(f) == 0);
fclose(f);
}
Linked from
Related notes
- tuts/c/stdlib/stdio/feof Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/perror Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fflush shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fgets shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fprintf shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fputs shared tags: #c, #prog, #stdio, #stdlib, #tier