Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>clearerr() clear error indicator for a stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 clearerr()              Clear Error Indicator for a Stream

 #include <stdio.h>

 void       clearerr(stream);
 FILE       *stream;                     Pointer to file structure

    clearerr() sets the error and end-of-file indicators of the 'stream'
    to 0.

       Returns:     Nothing

         Notes:     Once set, a stream's indicators are not automatically
                    cleared by subsequent operations; operations to the
                    stream will continue to return an error either until
                    clearerr() or rewind() is called, or the stream is
                    closed.

   -------------------------------- Example ---------------------------------

    The following statements open a file, get characters from the file,
    report an error, then clear the indicators (if necessary) and close
    the file.

           #include <stdio.h>

           FILE *stream;
           int c;

           main()
           {
               if ((stream = fopen("new.txt","r+"))!= NULL) {
                  while (!feof(stream)){
                        c = getc(stream);
                        if (ferror(stream)) {
                           printf("write error\n");
                           clearerr(stream);
                       }
                   }
                   fclose(stream);
               }
           }


See Also: eof() feof() ferror() perror()

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