Skip to main content

Relationship between Arrays and Pointers

Array of pointers

C program having an array of three pointers which are assigned the addresses of three integer variables.  
#include<stdio.h> 
main() 
{ int arr[3]={1,2,3}; 
int *ptr[3],i; 
for(i=0;i<3;i++) 
{ ptr[i]=arr+i; // assigning addresses of elements to array of pointers 
for(i=0;i<3;i++) 
{ printf(“\n address = %u value=%d”, ptr[i], *ptr[i]); } 

Here output will be address of elements and its value. 
Address = 3219018020 value=1 
Address = 3219018024 value=2 
Address = 3219018028 value=3


Comments