Declaring automatic variables inside a while loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Could you please let me know if it is 
valid to declare an automatic variable 
inside a for loop. If yes, is it also allowed
in ANSI standard (could you please refer
me to the sec #).

GCC Version : 2.95.3
Example:
void f()
{
    int i;
    i = 10;
    while(i >=0 )
    {
       int j;
       i=j;
       printf("j=%d \n", j);
       i--;
    }
return;
}

Also, in the above example would the number 
of iterations contribute anything to the stack
size since an automatic variable is declared
inside the while loop??

Your input is very much appreciated.

Thanks & Regards,
Swaminathan Venkat


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux