C program to print the array of pointers with example

C program to print the array of pointers with example. An array of pointers is an indexed set of variables with pointers as variables. In computer science, pointers are used to create, use, and delete various types of data structures. An array of pointers serves the same purpose as any other array: it helps you to numerically index a large number of variables.

#include <stdio.h>
const int MAX = 3; 
int main()
{
int var[]={10, 20, 30}; 
int i = 0;
int *ptr[MAX];
for(i = 0; i < MAX; i++)
{
ptr[i] = &var[i];
}
for(i = 0; i < MAX; i++)
{
printf("Value of variable[%d] = %i\n\n", i, *ptr[i]);
}
return 0;
}

Value of variable[0] = 10

Value of variable[1] = 20

Value of variable[2] = 30