3 ms·
really? I thought the reason is that the index is simply a memory offset. :\ a[0] always meant something like "get me the data whre a is pointing to" a[1] me
by k__ 13y ago
really?
I thought the reason is that the index is simply a memory offset. :\
a[0] always meant something like "get me the data whre a is pointing to"
a[1] meant "get me the data 1-offset next to where a is pointing to"
- VLM 13y agoTraditionally this is taught to noobs on a blackboard or I suppose powerpoint now. One based indexes are just going to confuse the noobs even worse. "So a[2] means get me the data offset by one from a" "uh what, don't you mean offset by two?" "No somebody said pointer arithmetic would be simpler if you had to memorize a bunch of different times to add or subtract one, just as a barrier to entry". "Oh well that sucks. Someone should invent a zero indexed array language..."
- k__ 13y agoHum, funny... I always thought about arrays as pointers (at least in C), like it's just syntactical sugar for specific kind of pointer.