C/C++ Syntax Reference - Accessing an Array
Accessing an Element of an ArrayTo access an individual element of an array, use the name of the array name followed by the index of the element in square brackets. Array indices start at 0 and end at size-1:
array_name[index];accesses the index'th element of array_name starting at zero. If index is 0, then the first element is accessed. For instance,
int myArray; myArray = 4;sets the first element of myArray to 4. Note that it is not valid to attempt to access myArray -- this is outside the bounds of the array.
To access an array with multiple dimensions, a similar approach is used, expect that each dimension requires an explicit index:
int myArray; myArray = 45;sets position 3, 4 in myArray to 45 (why might that be?)