The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017



The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at ferror.

Tests for an error on a stream.

int ferror(   
   FILE *stream   


Pointer to FILE structure.

If no error has occurred on stream, ferror returns 0. Otherwise, it returns a nonzero value. If stream is NULL, ferror invokes the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, this function sets errno to EINVAL and returns 0.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, error codes.

The ferror routine (implemented both as a function and as a macro) tests for a reading or writing error on the file associated with stream. If an error has occurred, the error indicator for the stream remains set until the stream is closed or rewound, or until clearerr is called against it.

FunctionRequired header

For additional compatibility information, see Compatibility in the Introduction.

See the example for feof.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Error Handling
Stream I/O
fopen, _wfopen
perror, _wperror