0

I am trying to figure out the difference if any between these two lines of code. I exceeded the index limit and that in return outputted garbage as expected for both so they behave the same I presume but I am unsure and wanted to get an definite answer.

Thank you in advance.

arr[] = {1,2,3,4,5,6};
cout << arr[5] <<  endl;   
cout <<  5[arr] << endl;

Steel
  • 1
  • Already answered here: https://stackoverflow.com/questions/381542 They are internally understood as `*(arr+5)` which is the same as `*(5+arr)` – André Caceres Feb 09 '20 at 00:41
  • Does this answer your question? [With arrays, why is it the case that a\[5\] == 5\[a\]?](https://stackoverflow.com/questions/381542/with-arrays-why-is-it-the-case-that-a5-5a) – Zheng Qu Feb 09 '20 at 00:46

0 Answers0