Retrieve Data from an Array Using an Array of Pointers - C Pointer

C examples for Pointer:Array Pointer

Description

Retrieve Data from an Array Using an Array of Pointers

Demo Code

#include <stdio.h>

int main()/*from w ww.  java  2  s .  com*/
{
     int intArray[6];
     int *ptrArray[6];
    
     for(int i = 0; i < 6; i++) {
        intArray[i] = (i + 2) * 100;
        ptrArray[i] = &intArray[i ];
     }
    
     for(int i = 0; i < 6; i++)
         printf("intArray[%d], Value: %d, Address: %u\n",
                                    i, *(ptrArray[i]), ptrArray[i]);
    
     return(0);
}

Related Tutorials