Why cannot use pointer of pointer as parameter to declare a function receive pointer of array

后端 未结 2 1154
攒了一身酷
攒了一身酷 2021-01-24 17:03

I have a c function receiving pointer of array as its one parameter.

Since pass an array is actually the pointer of its first element, so the pointer of an array should

2条回答
  •  半阙折子戏
    2021-01-24 17:59

    so the pointer of an array should be a pointer of pointer.

    No. Arrays are not pointers. Pointer to pointer and pointer to array both are of different types.

    &arr is of type int (*)[4]. You are passing an argument of type pointer to an array of 4 int while your function expects argument of type int **.

    Change the function declaration to

    int receiveArrayPtr(int (*arrPtrPara)[4])
    

提交回复
热议问题