This shows you the differences between two versions of the page.
c:stdio.h:ferror [2013/01/22 22:02] 127.0.0.1 external edit |
c:stdio.h:ferror [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 23: | Line 23: | ||
handle = fopen("test.txt","r"); | handle = fopen("test.txt","r"); | ||
- | if (handle!=NULL) | + | if (handle!=NULL) { |
- | { | + | |
printf ("its all fine\n"); | printf ("its all fine\n"); | ||
putc('X',handle); | putc('X',handle); | ||
if (ferror(handle)) { printf ("error in writing to file\n");} | if (ferror(handle)) { printf ("error in writing to file\n");} | ||
fclose (handle); | fclose (handle); | ||
+ | } else { | ||
+ | perror ("error opening file for reading\n"); | ||
} | } | ||
- | else | ||
- | { | ||
- | perror ("error opening file for reading\n"); | ||
- | } | ||
return 0; | return 0; | ||
} | } |