B
Bill Cunningham
I just wanted to get some opinions on FIlE streams and error checking
methods. I thought about EOF, NULL, and ferror. I have had trouble with EOF
so there must be something there I'm not doing right. As far as style or a
commonly used method is EOF perferred over ferror? Here's a snippet
char buf[20];
FILE *fp;
fp=fopen("file","rb+");
if(fread (buf,20,sizeof(char),fp)==EOF) {fclose(fp);}
/* I know I need error checking as well as EOF but this is a skeleton that
just opens and closes a stream */
Would it be less messy to use ferror() or NULL? Is there a perferred way?
Bill
methods. I thought about EOF, NULL, and ferror. I have had trouble with EOF
so there must be something there I'm not doing right. As far as style or a
commonly used method is EOF perferred over ferror? Here's a snippet
char buf[20];
FILE *fp;
fp=fopen("file","rb+");
if(fread (buf,20,sizeof(char),fp)==EOF) {fclose(fp);}
/* I know I need error checking as well as EOF but this is a skeleton that
just opens and closes a stream */
Would it be less messy to use ferror() or NULL? Is there a perferred way?
Bill