Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!dkuug!iesd!iesd.auc.dk!richard From: richard@iesd.auc.dk (Richard Flamsholt S0rensen) Newsgroups: comp.lang.c Subject: Re: Using `=' in a conditional (was Re: Funny mistake) Message-ID: Date: 18 Mar 91 12:57:57 GMT References: <1991Mar13.125034.2825@st-andy.uucp> <13337@helios.TAMU.EDU> <8148@rsiatl.Dixie.Com> <15481@smoke.brl.mil> <775@camco.Celestial.COM> Sender: news@iesd.auc.dk Distribution: comp Organization: Mathematics and Computer Science, University of Aalborg Lines: 19 In-reply-to: bevan@cs.man.ac.uk's message of 17 Mar 91 19:26:22 GMT >>>>> On 17 Mar 91 19:26:22 GMT, bevan@cs.man.ac.uk (Stephen J Bevan) said: Stephen> For what its worth, I haven't been programming in C that long (3 - 4 Stephen> years), but I can't actually remember using a `=' when I meant `=='. The keyboard on Sun's SparcStations are quite slow; I've often writen stuf containing only one letter (oops, mised that one ;-) where it should have been a double letter and that's bit me once or twice with the == versus = . Just my $0.02: using "if (x)" signals, that we're testing the boolean value of x rather than testing whether x != 0. The reason for using "if (x != 0)" is exactly the same reason why you write NULL or '\0' instead of plain 0 always; you want your code to syntactically signal your intensions. -- /Richard Flamsholt richard@iesd.auc.dk