I was just playing with pointers and found this weird thing. I created the pointer p and displayed its address as I did in the following program, the address of p and &p is different, why are they different?
int main()
{
int *p, s[5];
cout << p <<endl;
cout << &p <<endl;
p = s;
cout << p <<endl;
cout << &p <<endl;
}
Pis a pointer that means it holds an address to an integer. So when you print p it displays address of the integer it points to. Whereas when you print&pyou are actually printing the address of p itself rather than the address it points to.