related to pointes and arrays
what is difference between array of pointers and pointer array?
Posted Answers
hi,
we know, array is nothing but collection of elements with similar type.
ex: int arr[3]={1,2,3};
the array arr stores 3 integer elements in sequential memory locations.so this is called as array of integer elements.as like that,array of pointers means the array stores the addresses of int/float or etc.
ex:
int *arr[3]; int a=1,b=2,c=3; arr[0]=&a; arr[1]=&b; arr[2]; //array stores the addresses of variables a,b,c,not values.
pointer array means stores or access the address of array.
ex:
int (*arr)[]; //pointer to arr[3] int brr[3]={1,2,3};//array with 3 elements arr=brr; or arr=&brr;//stores the address of array.
another difference is the increment or decrement of array of pointers is as like normal arrays,just give next location/previous location.but if u increment/decrement on pointer array,then it is give next starting array.
ex:
int (*arr)[3]; //pointer array int brr[2]={1,2}; //array with 2 integer elements arr=&brr; //assume starting address is 2100 arr++; //this is on 2106 th location // sizeof(int)*3.
my id is "sudheer.013@gmail.com"
Answer by: Anonymous
