Skip to main content

Initializing pointer to pointer

An array of pointers and a pointer can be initialized during declaration as illustrated by following examples. 

int a[]={0,1,2,3,4}; 
int *p[]={a,a+1,a+2,a+3,a+4}; 
int **ptr=p; 

Here ‘a’ is an array of integers, ‘p’ is an array of pointers which stores addresses of array elements and ‘ptr’ is a pointer to pointer which stores base address of array ‘p’.

Comments