What is pointer to pointer in C Language?
In case of a pointer to pointer concept, one pointer refers to the address of another pointer. The pointer to pointer is a chain of pointers. Generally, the pointer contains the address of a variable. The pointer to pointer contains the address of a first pointer. Let’s understand this concept through an example:
- #include <stdio.h>
- int main()
- {
- int a=10;
- int *ptr,**pptr; // *ptr is a pointer and **pptr is a double pointer.
- ptr=&a;
- pptr=&ptr;
- printf(“value of a is:%d”,a);
- printf(“\n”);
- printf(“value of *ptr is : %d”,*ptr);
- printf(“\n”);
- printf(“value of **pptr is : %d”,**pptr);
- return 0;
- }
In the above example, pptr is a double pointer pointing to the address of the ptr variable and ptr points to the address of ‘a’ variable.
Recent Posts