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
Post a Comment