/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* clearerr() resets  the error indicator and  EOF
   to 0 on the same stream */
#include <stdio.h>

int main() {
    FILE *fp;
    char ch; 
    
    if((fp = fopen("clearerr.c","r")) == NULL) {
        fprintf(stderr, "Error: cannot open file clearerr.c for reading\n");
        exit(1);
    }
    while(!feof(fp)) {
        ch = fgetc(fp);
    }
    printf("feof(fp) is %2d before clearerr(fp) is called.\n", feof(fp));
    clearerr(fp);
    printf("feof(fp) is %2d after clearerr(fp) is called.\n", feof(fp));
 }
