Reset error flag

From , 4 Years ago, written in C, viewed 59 times.
URL https://pastebin.vip/view/05a70454
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.    FILE *fp;
  6.    char ch;
  7.  
  8.    /* open a file for writing */
  9.    fp = fopen("DUMMY.FIL", "w");
  10.  
  11.    /* force an error condition by attempting to read */
  12.    ch = fgetc(fp);
  13.    printf("%c\n",ch);
  14.  
  15.    if (ferror(fp))
  16.    {
  17.       /* display an error message */
  18.       printf("Error reading from DUMMY.FIL\n");
  19.  
  20.       /* reset the error and EOF indicators */
  21.       clearerr(fp);
  22.    }
  23.  
  24.    fclose(fp);
  25.    return 0;
  26. }

Reply to "Reset error flag"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website