Lately i've been researching on pointers and memory locations, and something doest seem right to me:
I wrote this little program:
Code:
#include <iostream>
using namespace std;
int main()
{
int c1 = 3;
int a;
bool sch;
cout <<"Variable c == " <<c1 <<", and its located at: " <<(int)&c1 <<endl;
cin >>sch;
cin.ignore(100, '\n');
switch (sch)
{
case 1:
{
cout <<"Change: ";
cin >>c1;
} break;
default: break;
}
cout <<"Variable c == " <<c1 <<" Located at: " <<(int)&c1 <<endl;
cin.ignore(100, '\n');
cin.get();
}
The problem here is that when i run it, the variable c1 is always alocated in the same memory position, and my question is, shouldnt it change every time i run the program??
and another thing, when i open multiple instances of that program, all the instances show c1 located in the same memory space, how is that possible??
help pls.