I've started learning about pointers and I ended up with a question over functions and pointers. I created a simple function that should return the address/pointer of an Integer type. However, after printing the address using "&" it differs from what the function returns me. What am I missing here?
int* address_ofInt(int a) {
return &a;
}
int main() {
int foo = 124;
std::cout << &foo << std::endl;
std::cout << address_ofInt(foo) << std::endl;
return 0;
}
// It outputs
// 0x7ffee2434b08
// 0x7ffee2434acc