For-loop Local Variables in C -


why following code output same memory location everytime?

int x; (x = 0; x < 10; x++) {     int y = 10;     printf("%p\n", &y); } 

i thought memory location should change each time for-loop run, variable new.

yes, absolutely right memory location could change. doesn't have :). in each iteration old variable "destroyed" , new 1 "created" @ same place. although decent compiler optimize unnecessary "actions" away


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -