Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!bridge2!3comvax!tymix!cirrusl!dhesi%cirrusl From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: TO C OR NOT TO *C Message-ID: <991@cirrusl.UUCP> Date: 18 Oct 89 05:37:28 GMT References: <16107@nswitgould.cs.uts.oz> <1989Oct16.172249.18387@utzoo.uucp> Sender: news@cirrusl.UUCP Reply-To: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Organization: Cirrus Logic Inc. Lines: 26 In article <1989Oct16.172249.18387@utzoo.uucp> henry@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. | Rahul Dhesi UUCP: oliveb!cirrusl!dhesi Do not use From: address for reply if it contains "sun".