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++ 3.0r4 - <b>clearerr</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
clearerr

Usage

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

   ANSI


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>
   #include <stdlib.h>

   int 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);
               fclose(stream);
               return EXIT_FAILURE;
           }
       printf("No error writing to file\n");
       fclose(stream);
       return EXIT_SUCCESS;
   }

See Also

   feof, ferror



See Also: feof ferror

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