Pointer to Pointer in C
In this program, you will learn about the concept of pointer to pointer and get the example code of pointer to pointer in c programming.
What is pointer to pointer
Pointer to pointer is a type of variable that stores the address of another pointer. A double pointer is another name for it. It is used to send the address of a pointer to a function or to pass a pointer by reference.
For example:
int a = 5;
int *b;
int **c;
b = &a; // b points to the address of a
c = &b; // c points to the address of b
In above example, c is a pointer to a pointer. It stores the address of b, which is a pointer to the integer variable a.
Pointer to Pointer in C example
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<stdio.h> int main() { int a = 5; int *p; int **pp; p = &a; pp = &p; printf("Value of a: %d\n", a); printf("Value of *p: %d\n", *p); printf("Value of **pp: %d\n", **pp); return 0; } |
Output
Value of a: 5
Value of *p: 5
Value of **pp: 5
Check out our other C programming Examples