home *** CD-ROM | disk | FTP | other *** search
- main() /* ferror.c -- illustrates use of ferror() */
- {FILE *fp;
- char name[20], c;
- int ret;
-
- printf("Filename: ");
- gets(name);
- ret = ferror(fp);
- if(ret == -1)
- puts("You're file had an error condition; we fix");
- puts("No error condition detected.");
- clrerr(fp);
- if ((fp = fopen(name,"r")) == NULL)
- exit();
- while((c = getc(fp)) != EOF)
- putchar(c);
- fclose(fp);
-
- }