int main(int argc, char *argv[])
{
int *p=5,**P;
printf("%d",&P);
}
What is the difference between *p and **P?
int main(int argc, char *argv[])
{
int *p=5,**P;
printf("%d",&P);
}
What is the difference between *p and **P?
*p is a pointer which points to an int that is equal to 5
**P is a pointer to A pointer;it is a variable that contains an address.
A pointer is a variable that contains an address. In your PC every variable is stored in a certain place in its memory. The exact place where a variable is placed is called variable's address.
With a pointer you are able to know the exact address of another variable.
Example
int c = 5; // this value of this int is stored at a certain address;
int *p = &c; // the pointer p now contains the address where 5
Keep in mind that *p is a variable too and as such is stored somewhere in the memory as well.
int **P = &p ; // a double pointer that contains the address of the pointer p
this will be a new pointer that points to the address where p is stored ( not the variable c!) –a pointer;
A single asterisks represents a pointer whereas a double asterisks represents a pointer to a pointer.
*p is an address to an int that equals 5. So somewhere in memory, there is an int that equals 5 and that pointer points to that address of that int.
**p is an address to a pointer in memory. So think of it that we have a pointer pointing to the int above, but now on top of that, we have another pointer pointing to the pointer for the int. Another way to think of it is we have an address for another address that's for the int.