🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C Notes
Topic #60

Pointer to Pointer


Pointer to Pointer

You can also have a pointer that points to another pointer. This is called a pointer to pointer (or "double pointer").

It might sound confusing at first, but it's just one more level of indirection: a pointer that stores the address of another pointer.

Note: Think of it like this: A normal pointer is like a note with an address on it. A pointer to pointer is like another note telling you where that first note is kept. Note: Pointer to pointer is not something you need to use often as a beginner. However, you might see it in more advanced programs, so it's good to understand what it means and how it works.

Let's look at a simple example to understand how this works:

Example

int myNum = 10;       // normal variable
int *ptr = &myNum;    // pointer to int
int **pptr = &ptr;    // pointer to pointer

printf("myNum = %d\n", myNum);
printf("*ptr = %d\n", *ptr);
printf("**pptr = %d\n", **pptr);

Here's what happens step by step:

  • myNum holds the value 10.
  • ptr holds the address of myNum.
  • pptr holds the address of ptr.
  • *ptr gives the value of myNum.
  • **pptr also gives the value of myNum, by going through both pointers.

So:

  • *ptr = value of myNum
  • **pptr = value of myNum through both levels

Changing Values Through a Pointer to Pointer

Since **pptr accesses the original variable, you can use it to change the value of the variable too:

Example

int myNum = 5;
int *ptr = &myNum;
int **pptr = &ptr;

**pptr = 20; // changes myNum

printf("myNum = %d\n", myNum); // prints 20

Summary

  • A pointer to pointer stores the address of another pointer.
  • *ptr gives the value of a variable.
  • **pptr gives the same value by following two levels of indirection.
  • They can be useful when passing pointers to functions or working with complex data structures.

Want to go beyond the notes?

Join CodingNow 2.0's C course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Pointer to Pointer – FAQs

Quick answers about learning Pointer to Pointer in C.

This free note from CodingNow 2.0 explains Pointer to Pointer in C — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C topic on CodingNow 2.0, including Pointer to Pointer, is 100% free with no signup required.
With focused practice, most students grasp Pointer to Pointer in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now