Declaration within a loop.

Conor P. Cahill cpcahil at virtech.UUCP
Thu Sep 28 01:52:12 AEST 1989


In article <2085 at hydra.gatech.EDU>, dvu at prism.gatech.EDU (Dinh Vu) writes:
> Is it true that every time through the loop, a new i variable
> is declared (more memory allocated ??)?  Or the same i variable
> is reused...  I see something similiar to this in the GNU 'make' 
> source code.  Also, if I run the code above long enough, will it 
> take all memory.  Thanks.

The variable i is an automatic variable allocated on the stack at the
start of block.  It is not re-allocated each time through the loop. 
This kind of thing can be verified by creating a small source code file
and compiling it with the -S flag to get the assembly language.

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list