Re: for loop (c-lang)
- From: Marco van de Voort <marcov@xxxxxxxx>
- Date: Wed, 28 Feb 2007 13:06:07 +0000 (UTC)
On 2007-02-28, Dodgy <Dodgy@xxxxxxxxxxxxxxxxxxxxx> wrote:
for( ; 0 ;)
printf("Why"); ???
For loops will always execute at least once as the end condition is
only ever checked at the end of the code block, where the "next" would
be in basic.
Bollocks. A for loop is a while loop.
Well it might be in Delphi, not sure, can honestly say if I've ever
tried to do a loop zero times in a for, but from the programming
background I come from "for" and "repeat" loops have the comparison at
the end, a "while" has it at the beginning.
Correct for repeat and while, and the C for is equal to the while.
The Pascal for is not equal to while, the biggest difference is that the
number of iterations must be (runtime) constant at the moment the loops
start. Delphi added the check for 0 iterations afaik. (TP didn't)
Note to the assembler fiddlers, for loops with a constant compiletime number
of iterations might look totally different in asm from ones that have a
variable for at least one bound.
.
- References:
- for loop (c-lang)
- From: mohdalibaig
- Re: for loop (c-lang)
- From: Dodgy
- Re: for loop (c-lang)
- From: Maarten Wiltink
- Re: for loop (c-lang)
- From: Dodgy
- for loop (c-lang)
- Prev by Date: Re: for loop (c-lang)
- Next by Date: Re: SetString
- Previous by thread: Re: for loop (c-lang)
- Next by thread: Re: for loop (c-lang)
- Index(es):
Relevant Pages
|