Content deleted Content added
→One-dimensional arrays: Never in my life have I ever heard anyone refer to an element as 'zeroth'. Tag: Reverted |
Undid revision 1104391891 by 87.209.228.223 (talk) |
||
Line 67:
For a vector with linear addressing, the element with index ''i'' is located at the address {{nowrap|''B'' + ''c'' × ''i''}}, where ''B'' is a fixed ''base address'' and ''c'' a fixed constant, sometimes called the ''address increment'' or ''stride''.
If the valid element indices begin at 0, the constant ''B'' is simply the address of the first element of the array. For this reason, the [[C (programming language)|C programming language]] specifies that array indices always begin at 0; and
However, one can choose the index of the first element by an appropriate choice of the base address ''B''. For example, if the array has five elements, indexed 1 through 5, and the base address ''B'' is replaced by {{nowrap|''B'' + 30''c''}}, then the indices of those same elements will be 31 to 35. If the numbering does not start at 0, the constant ''B'' may not be the address of any element.
|