Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <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 stream's error and end-of-file indicators to 0.

    Returns:    No return value.

      Notes:    Once set, a stream's indicators are not automatically
                cleared by subsequent operations; operations to the
                stream will thus continue to return an error until either
                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