函数名: ferror
功 能: 检测流上的错误
用 法: #include <stdio.h>
int ferror(FILE *stream);
程序例:
#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 an 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;
}