Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!spdcc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: EOF considered harmful Message-ID: <732@lakart.UUCP> Date: 27 Oct 89 16:29:18 GMT References: <266@m1.cs.man.ac.uk> Organization: Lakart Corporation, Newton, MA Lines: 23 ian@r6.UUCP (Ian Cottam) sez: > 3) The, to my mind, awful idiom in 1) above is avoided, with the extra > benefit that the ``(ch= getchar() != EOF)'' slip up will not be made. while (EOF != (ch = getchar())) putchar(ch); NOW try leaving the parentheses off the (ch = getchar()) bit. As a side note (and as has already been observed) the general construct: if (CONSTANT == variable) will always be safer than: if (variable == CONSTANT) because CONSTANT isn't an lvalue, so the compiler complains if you put = instead of == -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+