Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!dino!news.iastate.edu!IASTATE.EDU!john From: john@IASTATE.EDU (Hascall John Paul) Newsgroups: comp.lang.c Subject: Re: a style question Message-ID: <1990Oct2.192727@IASTATE.EDU> Date: 3 Oct 90 00:27:27 GMT References: <7341@darkstar.ucsc.edu> <1990Sep30.050655.13212@zoo.toronto.edu> <1990Sep30.172917.2951@Neon.Stanford.EDU> <1990Oct1.174941.22195@zoo.toronto.edu> <18370@haddock.ima.isc.com> Sender: usenet@news.iastate.edu (USENET News Poster) Reply-To: john@IASTATE.EDU (Hascall John Paul) Organization: Iowa State University Lines: 23 In article <18370@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes: > Note that with either Henry's example or mine you will lose big if x is an > unsigned integer (and if you don't use lint to catch it). I usually use > for (x = 100; x != 0; --x) > on unsigned countdown loops where the index doesn't matter (i.e. just "do 100 > times"); if you actually need the interval [0,100), > for (x = 100; x-- != 0;) > does the job (though probably less efficiently). I suppose this is so hideous that I shall be cursed forever for it... ;-) unsigned int x; for (x = 100; (int)--x > 0; ) -- John Hascall An ill-chosen word is the fool's messenger. Project Vincent Iowa State University Computation Center john@iastate.edu Ames, IA 50010 (515) 294-9551