#include <iostream>
using namespace std;
int main()
{
const int l_test = 999999999;
int *l_ptr = (int*) &l_test;
cout<<"Constant Addr:"<<&l_test<<" Value:"<<l_test<<endl;
cout<<"Pointer Addr:"<<l_ptr<<" Value:"<<*l_ptr<<endl;
*l_ptr = 888888888; // Manipulating the pointer
cout<<"-------------------------------"<<endl;
cout<<"Constant Addr:"<<&l_test<<" Value:"<<l_test<<endl;
cout<<"Pointer Addr:"<<l_ptr<<" Value:"<<*l_ptr<<endl;
return 0;
}
The o/p for this program is
Constant Addr:0012FF7C Value:999999999
Pointer Addr:0012FF7C Value:999999999
-------------------------------
Constant Addr:0012FF7C Value:999999999
Pointer Addr:0012FF7C Value:888888888
please look into the last 2 lines,
the question is : how can same address 0012FF7C have 2 different values 888888888 & 999999999
Thanks ,