Previous Page
Next Page

ferror

Tests whether a file access error has occurred

#include <stdio.h>
int ferror ( FILE *fp  );

The ferror( ) functionoften implemented as a macrotests whether an error has been registered in reading or writing a given file.

ferror( )'s argument is a FILE pointer. One attribute of the file or stream referenced by this pointer is an error flag which indicates that an error has occurred during a read or write operation. The ferror( ) function or macro tests the error flag and returns a nonzero value if the flag is set. If not, ferror( ) returns 0.

Example

See the examples for clearerr( ) and fclose( ) in this chapter.

See Also

rewind( ), clearerr( ), feof( )


Previous Page
Next Page