Hi all,

Out of curiosity, why does an array start with 0 instead of 1? It would cut down of alot of confusion if it did.

Thanks

Recommended Answers

All 3 Replies

You not gone be first asking such a question. If you google in most programmming forums such a question been asked. I do not know the answer but I presume it is from past times of old languages like assembler, pascal etc where programer besides of creating program had to keep an eye on memory management. All computer data are digitally organized(ie in binary) even today 0- 0000, 1-0001, 2 0010, 3-0011...
It is said the C programming language actualy made zero array position widely used. Duno....
If you interested may want to read this document by Edsger W. Dijkstra called Why numbering should start at zero

Just a stab in the dark, but I, too, think it's memory management. An array is represented in memory by a pointer to its first element. The index of the array can indicate the offset from the value of that pointer.

Thanks cscgal. That makes alot of sense. Still would be nice if it started at 1 and used 0 as an offset instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.