C Standard Library: Error Functions

1.7 Error Functions

Many of the functions in the library set status indicators when error or end of file occur. These
indicators may be set and tested explicitly. In addition, the integer expression errno (declared
in <errno.h>) may contain an error number that gives further information about the most
recent error.


void clearerr(FILE *stream)
clearerr clears the end of file and error indicators for stream.


int feof(FILE *stream)
feof returns non-zero if the end of file indicator for stream is set.


int ferror(FILE *stream)
ferror returns non-zero if the error indicator for stream is set.


void perror(const char *s)
perror(s) prints s and an implementation-defined error message corresponding to the
integer in errno, as if by
fprintf(stderr, "%s: %s\n", s, "error message");

posted @ 2013-03-20 22:57  freewater  阅读(226)  评论(0编辑  收藏  举报