Why is the same value output for A[0], &A, and *A?

前端 未结 4 1164
攒了一身酷
攒了一身酷 2020-12-07 00:21

I am doing a little experiment.

#include
#include
using namespace std;
int main()
{

  int A[5][5];
  cout<

        
4条回答
  •  一整个雨季
    2020-12-07 00:45

    A[0] This equivalent to *(A + 0), or more simply *A.

    &A is a little more tricky. A is of type int[5][5], which is represented by a continous region of 100 bytes on the stack. The address of A is the start of that region - which is equal to the pointer to the first element. That first elements adress is also the storage location of *A.

提交回复
热议问题