News for hackers. Stuff that matters.
Re:Why do arrays start at 0? by fsckboy on Wednesday August 24, 2022 @10:32PM (#32588719)
it's a good idea to call the 0th element of an array the zeroth element, else you encourage off-by-one errors. The size of the array, the "count", is that which your index must be less than.

I'm not saying it has to be this way and it can't start with 1, I'm saying what you are pointing out as a flaw is actually the mixing of systems.

in computer programming teams it's best to adopt a standard unambiguous language to communicate to one another so as not have to constantly say "do you mean...?"

Re:Why do arrays start at 0? by iopq on Thursday August 25, 2022 @02:27AM (#32590285)
No, it's the first element, if it's a 32 bit int it still occupies bytes

0..4

the second int occupies bytes

4..8

you can see the array up to the second int occupies the contiguous space 0..8 which 0..4*2 and it has TWO elements