Answer: a pointer to pointer (double pointer) is a variable that stores the address of another pointer variable. It is declared with two asterisks, e.g. int **pp;
A normal pointer int *p holds the address of an int. A pointer to pointer int **pp holds the address of p. So there are two levels of indirection:
pp= address ofp*pp= value ofp= address ofx**pp= value ofx
#include <stdio.h>
int main()
{
int x = 10;
int *p = &x; /* p stores address of x */
int **pp = &p; /* pp stores address of p */
printf("x = %d\n", x); /* 10 */
printf("*p = %d\n", *p); /* 10 */
printf("**pp = %d\n", **pp); /* 10 */
**pp = 20; /* changes x through pp */
printf("x now = %d\n", x); /* 20 */
return 0;
}
Picture it as a chain: pp → p → x (value 10). Changing **pp changes x itself.
Uses: changing a pointer inside a function (pass &p to a function that takes int **), dynamic 2-D arrays (int **mat), and arrays of strings such as char **argv in main.