In article <991 at cirrusl.UUCP>, dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
> 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);
And the same code could have been done without the break, without the
overhead of the feof() function call for every iteration of the loop
and (in my humble opinion) more readable as follows:
int c;
while( (c=getc(stdin)) != EOF);
{
.. do stuff with c ..
}
--
+-----------------------------------------------------------------------+
| Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 !
| Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 |
+-----------------------------------------------------------------------+