Pointer to Pointer in C Programming
Pointer to Pointer in C Programming
Introduction to Pointer to Pointer
A pointer to pointer in C programming is a variable that stores the address of another pointer. It is also called a double pointer.
Pointer to pointer in C programming is useful when working with dynamic memory, arrays of pointers, and advanced data structures.
What is Pointer to Pointer in C Programming
A pointer to pointer is declared using two asterisks **.
Syntax
Example
int *ptr = &a;
int **pptr = &ptr;
Here:
ais a normal variableptrstores address ofapptrstores address ofptr
Accessing Values Using Pointer to Pointer
You can access values at different levels.
Example
int main() {
int a = 5;
int *ptr = &a;
int **pptr = &ptr;
printf(“Value of a = %d\n”, a);
printf(“Using ptr = %d\n”, *ptr);
printf(“Using pptr = %d”, **pptr);
return 0;
}
Memory Representation of Pointer to Pointer
a→ stores valueptr→ stores address ofapptr→ stores address ofptr
Example: Modify Value Using Pointer to Pointer
void update(int **p) {
**p = 50;
}
int main() {
int a = 10;
int *ptr = &a;
update(&ptr);
printf(“Updated value = %d”, a);
return 0;
}
Pointer to Pointer with Arrays
int main() {
int arr[3] = {10, 20, 30};
int *ptr = arr;
int **pptr = &ptr;
printf(“%d\n”, **pptr); // 10
printf(“%d\n”, *(*pptr + 1)); // 20
return 0;
}
Why Pointer to Pointer is Important
Key Benefits
- Used in dynamic memory allocation
- Helps in modifying pointers inside functions
- Useful in multi-level data structures
- Supports advanced programming concepts
Common Mistakes
Avoid These Errors
- Confusing * and **
- Wrong dereferencing
- Using uninitialized pointers
Start Learning C Programming
Practice pointer to pointer examples to understand multi-level memory access in C programming.
Summary
Pointer to pointer in C programming stores the address of another pointer. It is useful for advanced memory handling and function operations.
FAQs
What is pointer to pointer in C programming?
It is a pointer that stores the address of another pointer.
Why use double pointer?
To manage multiple levels of memory and modify pointers.
What does ** mean in C?
It represents a pointer to pointer.
How to access value using double pointer?
By using **pointer_name.



