Previous | Home | Next |
Description
The C library function, The clearerr() function Tfunction shall clear the end-of-file and error indicators for the stream to which stream points. clearerr resets the named stream’s error and end-of-file indicators to 0. Once the error indicator is set, stream operations continue to return error status until a call is made to clearerr or rewind. The end-of-file indicator is reset with each input operation.
Declaration
Following is the declaration for clearerr() function.
void clearerr ( FILE * stream );
Parameters
stream - This is the pointer to a FILE object the file to reset the error flags for.
Return Value
The clearerr function does not return anything.
Example
#include<stdio.h> int main(void) { FILE *f; char ch; f = fopen("web.txt", "w"); ch = fgetc(f); printf("%c",ch); if (ferror(f)) { printf("Error reading from web.txt"); clearerr(f); } fclose(f); return 0; }