gtpc2m0vC/C++ Language Support User's Guide

clearerr-Reset Error and End-of-File

This function resets the error indicator and end-of-file (EOF) indicator for the stream that stream points to. Generally, the indicators for a stream remain set until your program calls the clearerr or rewind function.

Format

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

stream
The open stream whose error and end-of-file (EOF) indicator are to be reset.

Normal Return

Returns no value.

Error Return

Not applicable.

Programming Considerations

None.

Examples

The following example reads a data stream and then checks that a read error has not occurred.

#include <stdio.h>
 
int main(void)
{
   char string[100];
   FILE *stream;
   int eofvalue;
 
   stream = fopen("myfile.dat", "r");
 
   /* scan an input stream until an end-of-file character is read */
   while (!feof(stream))
      fscanf(stream,"%s",&string[0]);
 
   /* print EOF value: will be nonzero */
   eofvalue=feof(stream);
   printf("feof value=%i\n",eofvalue);
 
   /* print EOF value-after clearerr, will be equal to zero */
   clearerr(stream);
   eofvalue=feof(stream);
   printf("feof value=%i\n",eofvalue);
}

Related Information

See Appendix E, Programming Support for the TPF File System for more information about TPF File System C Functions.