I have the following simple program which prints out the address of a local variable inside loop. I assume the address of that variable changes by iteration, but it was not. Could someone explain me why?
#include <iostream>
int main() {
for(int i=0; i<5; i++) {
float p = 3.14;
std::cout << "addr of p : " << &p << std::endl;
}
return 0;
}
result:
addr of p : 0x7fffda254c88
addr of p : 0x7fffda254c88
addr of p : 0x7fffda254c88
addr of p : 0x7fffda254c88
addr of p : 0x7fffda254c88