For example, for the following code, I know that p is a pointer, which points to the first element of the array arr, and I also know that the array will degenerate into an array under certain conditions, but why can the [] operation be performed on the pointer here?
#include<iostream>
using namespace std;
int main()
{
int arr[10];
arr[3] = 10;
int* p = arr;
cout << p[3];
return 0;
}
Is there any documentation for this?
run it online
E1[E2]is identical (by definition) to*((E1)+(E2))...".3[p]is not just valid, but it's the same asp[3]