a style question

Hascall John Paul john at IASTATE.EDU
Wed Oct 3 10:27:27 AEST 1990


In article <18370 at haddock.ima.isc.com>, karl at 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 at iastate.edu
Ames, IA  50010                                                  (515) 294-9551



More information about the Comp.lang.c mailing list