ferror
Tests the error indicator for a stream (function or macro)
#include <stdio.h>
int ferror (
FILE *fp);
ferror returns nonzero if the error indicator is set for fp.
The ferror function or macro tests the error indicator for the file pointed to by fp.
#include <stdio.h>
main ()
{
FILE *fp;
int c;
c = fgetc (fp);
if (ferror (fp) )
{ /* if end-of-file */
fclose (fp); /* close the file */
c = EOF;
}
}