Usually in c++, when traversing through an array you would count up and use the index. However, I am wondering why using the array as an index works as well. For example,
#include <iostream>
using namespace std;
int main() {
int a[] = {5,7,3,2,0};
int i = 0;
for(i = 0; i <5; i++)
{
cout<<i[a]<<"\n";
}
return 0;
}
The output would be the same as using a[i]. Why is this?