Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: James Kuyper Newsgroups: comp.lang.c Subject: Re: the loop control Date: Thu, 03 Nov 2011 18:00:13 -0400 Organization: A noiseless patient Spider Lines: 22 Message-ID: <4EB30EED.6020102@verizon.net> References: <20111031152454.835@kylheku.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="2P71cupDoazVVolqpw1jrw"; logging-data="30730"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nv2bhnsH6y9VM/1U1yhBuWxadgGZSU5I=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110920 Thunderbird/3.1.15 In-Reply-To: Cancel-Lock: sha1:PK6/0Y4jtn5yBF1xu0ZX/MCGWCc= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:12632 On 11/03/2011 05:29 PM, Joe keane wrote: > I use it all the time. > > The idiom > > while (--ct >= 0) > ... > > has the nice property that if ct is negative coming in [almost], the > body is not executed, which is probably what you want. A property it shares with while(ct-- > 0) which, in addition to the minor advantage of being one character shorter, also works as intended even if ct is unsigned. ... > If you need unsigned for a loop counter, there must be some reason for > doing so. That is correct.