Array Of Pointer - C Tutorial

Array Of Pointer

We can create an array of pointer in c.The array of pointers represents a collection of addresses.

An Array of pointers point to an array of data items.Each elements of the pointer array point to an item of the data array

Example - Array of Pointer Program

      #include 
int main()
{
    int a=10,b=20,c=30,d=40,e=50;
    
    int *arr[5];
    arr[0]=&a;
    arr[1]=&b;
    arr[2]=&c;
    arr[3]=&d;
    arr[4]=&e;
    
    printf("Value of a=%d\n",*arr[0]);
    printf("Value of b=%d\n",*arr[1]);
    printf("Value of c=%d\n",*arr[2]);
    printf("Value of d=%d\n",*arr[3]);
    printf("Value of e=%d\n",*arr[4]);
  
    return 0;
}

Output - Array of Pointer Program

Value of a=10                                                                                                           
Value of b=20                                                                                                           
Value of c=30                                                                                                           
Value of d=40                                                                                                           
Value of e=50