From mboxrd@z Thu Jan 1 00:00:00 1970 From: krewat@kilonet.net (Arthur Krewat) Date: Wed, 7 Jun 2017 14:46:29 -0400 Subject: [TUHS] Array index history In-Reply-To: References: Message-ID: <23afd785-e260-75ca-5c46-77c62fbcf3cd@kilonet.net> If you think of an array as a memory area of bytes, words, whatever, the simple way to deal with it is the index being 0 is the first in the array. Why go to the trouble of decrementing the index to retreive the first entry? ALGOL did indeed have arrays with bounds: INTEGER ARRAY K,L[0:10,0:10]; Two arrays, K and L with 0 first, 10 last. Total of 11 elements. Of course, it's a "higher level" language than C. My thinking on the subject is that C is very close to assembler, so if you're using for example Intel X86 instructions: MOV SI,1 MOV AL,[SI + ARRAY1] ; retrieve the SECOND element (byte) Likewise, for words, just left-shift SI one bit. For me having started out in assembler (actually, MACRO-10 on a PDP-10), it's intuitive as to why/how C does arrays. ak