difference between &array[0] and &array when passed to a C function

后端 未结 5 1385
礼貌的吻别
礼貌的吻别 2020-12-17 04:20

Is there a difference between &array[0] and &array when passed to a C Function. This array is a void* array which currently takes integer as data.

Added the

5条回答
  •  感情败类
    2020-12-17 05:12

    If array is really an array, then

    • &array[0] is the pointer to element 0 of array[]
    • &array is the pointer to the entire array[]

    So, these two expressions are of different types. And that's the main difference that may cause your code to fail to compile if you pass the wrong one of the two.

    At the low level, however, the two pointers are going to hold the same address.

提交回复
热议问题