Array Indexing

I briefly learned this stuff in my CS137 class.

Reviewed with Kajanan through my VR Headset Logs project.

Kajanan explained me some really fundamental stuff on how the array indexing actually works in memory

arr[i] == arr + i

By if you had casted arr as uint8_t* when arr is originally of type T, you actually need to do

arr + sizeof(T) * i
  • And this is actually what the compiler is doing under the hood

So then we can think in the 2D case for images as well.