C pointer to array/array of pointers disambiguation

前端 未结 13 1339
我寻月下人不归
我寻月下人不归 2020-11-21 05:19

What is the difference between the following declarations:

int* arr1[8];
int (*arr2)[8];
int *(arr3[8]);

What is the general rule for under

13条回答
  •  攒了一身酷
    2020-11-21 05:55

    I think we can use the simple rule ..

    example int * (*ptr)()[];
    start from ptr 
    

    " ptr is a pointer to " go towards right ..its ")" now go left its a "(" come out go right "()" so " to a function which takes no arguments " go left "and returns a pointer " go right "to an array" go left " of integers "

提交回复
热议问题