C pointer : array variable

后端 未结 7 501
盖世英雄少女心
盖世英雄少女心 2021-01-20 18:09

I read this in my book (and many sources on the internet):

The array variable points to the first element in the array.

7条回答
  •  礼貌的吻别
    2021-01-20 18:51

    The array variable signifies the entire memory block the array occupies, not only the array's first element. So array is not the same as array[0] (cf. sizeof array / sizeof array[0]). But the array's first element is located at the same memory address as the array itself.

    Saying the array points to the first element is also incorrect, in most circumstances, an array expression decays into a pointer to its first element, but they are different things (again cf. sizeof for example).

提交回复
热议问题