Bob Paddock ha scritto:
The "falls out" is the issue with me, as I see the {} as being "contained 
within",
the "}" was never crossed, so to me it was still the same {} block.  I could not
find this "reinitialize" issue in my old K&R book?

The condition of the loop must me somehow checked. When you reach the "}", the execution crosses braces boundary and jumps to the check of for loop condition. If you write:

for (;;)
{
        ...
}

the condition is not well visible, as it has been omitted, but think if you write:

for (i = 0; i < 10; i++)
{
        ...
}

when the execution reaches the "}", jumps to:

i < 10

and if the condition is true the block is re-executed from the beginning. So variables declared inside the block die and reborn at every round.

You can see very well this behavior with a step-by-step debugger execution: when executing a loop, if you reach the block end, the execution jumps to the line containing the loop condition, crossing braces boundary.



--
_|/ Francesco Sacchi - Develer S.r.l., R&D dept.
 |\ http://www.develer.com/


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to