C Pointer to Pointer

Intermediate
6 min read
Updated: Nov 2026
1 example

What Is Pointer to Pointer?

A pointer to pointer (int **pp) stores the address of another pointer. It is how a function changes the caller's pointer, how arrays of strings are passed (char **argv), and how dynamic 2D arrays are built.

Remember
int x = 10;
int *p  = &x;
int **pp = &p;
**pp = 20;       /* writes x */
*pp  = &y;       /* repoints p */

Cheat Sheet

Keep these facts handy while you work with Pointer to Pointer in C.

TopicDetail
Declaretype **name;
One level*pp is the pointer p
Two levels**pp is the object x
UseOutput pointer parameters

C Examples

Compile each example with gcc file.c -std=c11 -Wall -o out. Next: Function Pointers.

Example 1 — Write through and repoint with a double pointer

The function changes which object cur points to.

C
#include <stdio.h>

static void point_to(int **pp, int *target) {
    *pp = target;
}

int main(void) {
    int x = 10;
    int *p = &x;
    int **pp = &p;

    **pp = 20;
    printf("x = %d\n", x);

    int a = 1, b = 2;
    int *cur = &a;
    point_to(&cur, &b);
    printf("*cur = %d\n", *cur);
    return 0;
}

How It Works

  1. **pp follows two arrows from pp to x.
  2. point_to receives the address of cur, so *pp = target changes cur.
  3. Passing cur itself would only change a copy.

Edge Cases & Pitfalls

Check these before relying on Pointer to Pointer in real programs.

depth

Too many levels

Three-star pointers are rarely needed. Consider a struct instead.

null

Unchecked levels

Check each level (pp, *pp) before dereferencing deeper.

Key Takeaways

  • Level: each * adds indirection.
  • Output pointers: pass &ptr.
  • Use sparingly: clarity first.

One line: A pointer to pointer (int **pp) stores the address of another pointer.

Frequently Asked Questions

To let a function modify the caller's pointer, such as allocating memory into it, or to work with arrays of pointers like argv.
Use two asterisks: int **pp; It points to a variable of type int *.
Continue with "C Function Pointers" next. Store and call functions through pointers, tables, and callbacks. The C Pointers hub lists every topic in order.

Next: Function Pointers

Store and call functions through pointers, tables, and callbacks.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful