Why does the indexing in an array start with zero in C and not with 1?
In C, the name of an array is essentially a pointer [but see the comments], a reference to a memory location, and so the expression array[n]
refers to a memory location n
elements away from the starting element. This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array refers (0 elements away), so it should be denoted as array[0]
.
For more info:
http://developeronline.blogspot.com/2008/04/why-array-index-should-start-from-0.html