Hello,
When an array pointers created inside the main, program works. But when I intialize array of pointers outside main, compiler gives error as
Initializer element is not constant
This works
Code:
#include<stdio.h>
int main()
{
int a = 10, b = 20, c = 50, i;
int *p =&a;
int *arrop[3] = {p, &b, &c};
for(i = 0; i < 3; i++)
{
printf("Address = %d\t Value = %d\n", arrop[i], *arrop[i]);
}
return 0;
}
But this doesn't
Code:
#include<stdio.h>
int a = 10, b = 20, c = 50, i;
int *p =&a;
int *arrop[3] = {p, &b, &c};
int main()
{
for(i = 0; i < 3; i++)
{
printf("Address = %d\t Value = %d\n", arrop[i], *arrop[i]);
}
return 0;
}
I googled the error, but I didn't understand anything
Thanks