Reset error indicators: writing errors
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen("f.txt","r");
if (pFile==NULL)
perror ("Error opening file");
else {
fputc ('v',pFile);
if (ferror (pFile)) {
printf ("Error Writing to f.txt\n");
clearerr (pFile);
}
fgetc (pFile);
if (!ferror (pFile))
printf ("No errors.\n");
fclose (pFile);
}
return 0;
}
Related examples in the same category