How do I create an array of pointers in the C language?
#include <stdio.h>
int main()
{
int v1 = 10;
int v2 = 20;
int v3 = 30;
int* ptr_arr[3] = { &v1, &v2, &v3 };
for (int i = 0; i < 3; i++) {
printf("Value of v%d: %d \tAddress: %p \n", i + 1, *ptr_arr[i], ptr_arr[i]);
}
}
output:-
Value of v1: 10 Address: 0x7fff32e5d968
Value of v2: 20 Address: 0x7fff32e5d964
Value of v3: 30 Address: 0x7fff32e5d960
0 కామెంట్లు