TO C OR NOT TO *C

Rahul Dhesi dhesi%cirrusl at oliveb.ATC.olivetti.com
Wed Oct 18 15:37:28 AEST 1989


In article <1989Oct16.172249.18387 at utzoo.uucp> henry at utzoo.uucp (Henry
Spencer) writes:
>Unless you have reason to be *absolutely certain* that end-of-file will
>not occur when attempting to read that character, the result of getc should
>*never* be assigned to a char without first testing to see if it is equal
>to EOF. 

Playing Devil's advocate, we bravely yet blithely break Henry Spencer's
every rule:

     char c;

     c = getc(stdin);           /* Oops! forgot to test for EOF! */
     do {
        if feof(stdin)
           break;               /* WHEW! */
        .. do stuff with c ..
        c = getc(stdin);
     } while (1);
--
To BLUNGE or not to BLUNGE;    | Rahul Dhesi, Cirrusl Logic Inc.
That is the question.          | <dhesi%cirrusl at oliveb.ATC.olivetti.com>

Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!dhesi
Do not use From: address for reply if it contains "sun".



More information about the Comp.lang.c mailing list