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:    There is no return value.
 
      Notes:    Once set, a stream's indicators are not automatically
                cleared by subsequent operations; operations to the
                stream will 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);
          }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster