int main(){
int a=5; //It eats up some memory in your RAM. Cause you've declared a variable.
}Since each statement we declare in our program eats up some memory and in RAM the memory is divided into some random block which is called Memory block.So the variable a=5 has taken 4 bytes of Memory in the RAM memory Block.These Memory Block have some addresses What if we are interested in knowing that address?
int main(){
int a=5;
cout<<&a<<endl; //
}The output will be some 0x Decimal Value and depend on your Operating System.
int main(){
int a=5;
int b= &a; // Will it work??? It will throw an error but why??
cout<<b<<endl;
}The above program will throw an error because Memory Address changes every time when you compile the Program. And when you compile this program each time memory address changes with some random memory blocks and we can not store the random address into an variable. So whats the next Option. Here comes Pointer.
And now our program will run smoothly,
int main(){
int a=5;
int *ptr= &a;
cout<<ptr<<endl;
}