Whats the difference? Pointer to an array vs regular array

后端 未结 9 1684
梦如初夏
梦如初夏 2021-01-04 21:40

I\'m familiar with Java and trying to teach myself C/C++. I\'m stealing some curriculum from a class that is hosting their materials here. I unfortunately can\'t ask the tea

9条回答
  •  抹茶落季
    2021-01-04 22:26

    It is true that you can get most of array functionality by using a pointer to its first element. But compiler knows that a static array is composed of several elements and the most notable difference is the result of the sizeof operator.

    sizeof(pointerArray) = sizeof int*

    sizeof(array) = 10 * sizeof int

提交回复
热议问题