clearerr

Description

Resets the error indicator for a stream.

#include <stdio.h>

void clearerr( FILE *stream );

stream Pointer to FILE structure  

Remarks

The clearerr function resets the error indicator and end-of-file indicator for stream. Error indicators are not automatically cleared; once the error indicator for a specified stream is set, operations on that stream continue to return an error value until clearerr, fseek, fsetpos, or rewind is called.

Return Value

None.

Compatibility

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

_eof, feof, ferror, perror

Example

/* CLEARERR.C: This program creates an error on the standard input

* stream, then clears it so that future reads won't fail.

*/

#include <stdio.h>

void main( void )

{

int c;

/* Create an error by writing to standard input. */

putc( 'c', stdin );

if( ferror( stdin ) )

{

perror( "Write error" );

clearerr( stdin );

}

/* See if read causes an error. */

printf( "Will input cause an error? " );

c = getc( stdin );

if( ferror( stdin ) )

{

perror( "Read error" );

clearerr( stdin );

}

}

Output

Write error: Error 0

Will input cause an error? n