Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - clearerr http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   clearerr

   Usage
   #include <stdio.h>
   void clearerr(FILE *fp);

   Description
   Clears  error and EOF (end-of-file) flags associated with  the  stream
   fp. Once the error flag on a stream is set, any operation carried  out
   on  that stream will return an error status unless a call is  made  to
   clearerr.  Note  the  EOF flag is cleared with  each  input  from  the
   stream.

   Example
   #include <stdio.h>
   main()
   {
   FILE *stream;
   char *string = "Sample data";

        stream = fopen("file.dat","r");
        fprintf(stream,"%s\n",string);
        if(ferror(stream))
        {
             fprintf(stderr,"Write error to file.dat\n");
             clearerr(stream);
        }
        printf("No error writing to file\n");
        fclose(stream);
   }


See Also: feof ferror

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson