Pointer which holds address of another pointer is called as pointer to pointer. It is also called as double pointer. Syntax: int **ptr_to_ptr; Example: int i=10; int *ptr; //pointer to an integer int **ptr_to_ptr: //pointer to a pointer ptr=&i; ptr_to_ptr = &ptr; C Program to illustrate pointer to pointer. #include<stdio.h> void main() { int i=10,*p1,**p2; p1= &i; p2=&p1; printf(“\n the value of i is %d %d %d ”,i,*p1,**p2); printf(“\n the address of i is %u %u %u”,&i,p1,*p2); } In above program p1 is pointer and p2 is a pointer to pointer. Pointer to pointer is often used in handling of strings, multidimensional arrays. Also Read Static and Dynamic Memory Allocation Memory Leak and Dangling Pointer Memory Allocation for 2D Array Dynamic Memory Allocation Pointer Constant and Constant Pointer Pointer Declarations and the...
Comments
Post a Comment
Please give us feedback through comments