Re: for loop (c-lang)



On 26 Feb 2007 05:18:51 -0800, mohdalibaig@xxxxxxxxx waffled on about
something:

why does this loop execute once
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.

Same goes for repeat.. until... The conditional check is at the end on
the until.

However a while has the condition at the beginning, so it's possible
for a while loop to never execute.

As for why that code with no loop variable actually compiles, well
that's cos C is designed to make even the simplest piece of code you
wrote last week look like the output of a 5 rotor enigma machine.

Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES
.



Relevant Pages