What is difference between array of pointers and pointer to an array?

Array of pointers means an array who content are pointers i.e. address of any type of variable. For example:
int * arr[5];  //arr is an array which can hold address of five int variables.
float **arr[10]; //arrr is an array which can hold the address of address of ten float variables.
//Program for array of pointers:
void main(){
    static int i=5,j=10,k=15,l=20;
    int x;
    int *arr[4]={&i,&j,&k,&l};

While pointer to an array is a pointer which can hold the address of any array. For example:
int arr[5];
int (*ptr)[5];  //ptr is pointer to such array which size is five and content is int type data.
//Program for pointer to an array:
void main(){
    int x;
    int arr[3]={10,20,30};
    int (*ptr)[3];

No comments: