How Are C Arrays Represented In Memory?

后端 未结 8 722
醉话见心
醉话见心 2020-12-14 01:33

I believe I understand how normal variables and pointers are represented in memory if you are using C.

For example, it\'s easy to understand that a pointer Ptr will

8条回答
  •  执念已碎
    2020-12-14 02:18

    Your diagram is correct. The weirdness around &x has nothing to do with how arrays are represented in memory. It has to do with array->pointer decay. x by itself in value context decays into a pointer to its first element; i.e., it is equivalent to &x[0]. &x is a pointer to an array, and the fact that the two are numerically equal is just saying that the address of an array is numerically equal to the address of its first element.

提交回复
热议问题