Why do arrays start at 0?
Do you guy know why arrays are indexed at zero? So what’s actually happening under the hood here, let takes this example:
so if I want to get a second element here of test
, I should write test[2];
right?
What’s actually happening here is this test[2];
converts the the address of test
plus size of an int
times two
And because the first element lives at the zeroth location (its the zeroth offset), that why you could do like this:
that’s taking the address two and then offseting by test
.
C is fun…
read other posts