I experimented with a double pointer (pointer to pointer) and wanted to understand it correctly. I tried the following code
int main()
{
int y = 5;
int *p = &y;
int *q = &p;
printf("\n\n %p %p %p %p %d\n\n",q,&p,p,*q,*p);
return 0;
}
Now, in the above code, p is a pointer pointing to y, and q is a pointer pointing to p. I specifically did not use a double pointer (** q) to check what was happening. The compiler gave me a warning indicating an incompatible pointer type. When I executed the code, I realized that q is a pointer to p, so it contains the address p, but * q does not give me the value contained in p, that is, the address y, rather I got some spam value, This is because I did not declare q as a double pointer? Can someone explain why I get some weird value for * q?