paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
|
04-23-2005 13:18
A -for- loop will compile without error when an ";" is included after the terms, like this:
for (count=0; count < 3; ++count);
The code will compile, but when run, the for loop doesnt increment, just jumps to the value of the comparison operator (in this case: 3).
Is this intentional, or a bug?
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
04-23-2005 13:35
No, that's intentional. It treats "for (count=0; count < 3; ++count);" as a single statement, then treats everything contained within the braces as a seperate chunk of code. It actually does increment the for loop, since it ends up with a value of 3. It just doesn't treat the code within the following braces as part of that for loop, because you've told it that it isn't by putting that semicolon there.
|
paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
|
Thanks!
04-23-2005 14:04
Thanks for the clarification!
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."
|