----- Original Message ----- 
From: "Brett McCoy" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, August 05, 2008 3:21 PM
Subject: Re: [c-prog] error checking

> Yep, but you still shouldn't be comparing EOF to the file pointer you
> have just closed. You want to capture the output of fclose() into an
> int and then see what that value is.
>
> The man page says:
>
> RETURN VALUE
>       Upon successful completion 0 is returned.  Otherwise, EOF is
> returned and the global variable errno is  set  to
>       indicate  the  error.   In  either  case  any further access
> (including another call to fclose()) to the stream
>       results in undefined behaviour.

    Well I never really use errno.h or any of C90's error codes. I have 
thought of using perror and feof but I never use them. I guess I just like 
C89 old-fashioned error checking. So if I'm not using errno.h do I just 
disregard that returning of EOF ? I don't think gcc-3.4.6 or any version is 
quite fully C90 compliant yet if I'm correct. I misunderstood what EOF meant 
I think in the manual.

Bill

Reply via email to