Skip to content
doubtly

1 answer

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 of p
  • *pp = value of p = address of x
  • **pp = value of x
#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.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.