Pointer array is a collection of addresses.
if I write in a function
int *arr[4];
int i=2,j=5,k=7,l=9;
arr[0]=&i;
arr[1]=&j;
arr[2]=&k;
arr[3]=&l;
//there is no problem in the above code.
But if I write
int i=2,j=5,k=7,l=9;
int *arr[4]={&i,&j,&k,&l};//errors-illegal initializtion
if I write
int a[]={1,2,3,4,5};
int *p[]={a,a+1,a+2,a+3,a+4};//errors-illegal initialization
if I write
static int a[]={1,2,3,4,5};
static int *p[]={a,a+1,a+2,a+3,a+4};
//there is no problem in this.
Does it mean that I can never initialize a pointer array by the
addresses of auto variables at the time of its declarion?If yes then
why is this rule made?
Please explain the meaning of the error- illegal initialization.I
don't understand it properly.