Answer the question
In order to leave comments, you need to log in
Why are arr and &arr displayed the same way?
The code:
int arr[] = {1, 2};
cout << arr << '\n';
cout << &arr<< '\n';
cout << *arr << '\n';
cout << *&arr << '\n';
0x7ffec51bafa0
0x7ffec51bafa0
1
0x7ffec51bafa0
Answer the question
In order to leave comments, you need to log in
Arrays and pointers in C are not exactly the same thing. Perhaps I'll just give a link to SO (there is even an excerpt from the standard).
Roughly speaking, variables of type "array" do not always behave identically to variables of type "pointer to the first element of the array". In particular, in the well-known construction:
int arr[32] = {...};
size_t N = sizeof(arr) / sizeof(arr[0]);
&
, there is also an exception.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question