Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - If char a [10] is defined; What is the incorrect array element or pointer reference? Is it a [5-2]?
If char a [10] is defined; What is the incorrect array element or pointer reference? Is it a [5-2]?
If char a[ 10] is defined, the incorrect array element or pointer reference is a[ 10], because the subscripts of array elements are 0~9.

The general form of array elements is:

Array name [subscript], where the subscript can only be an integer constant or an integer expression. If it is decimal, C compilation will be rounded automatically.

For example: a[5], a[i+j], a[i++]

The addresses of arrays and array elements are expressed as follows: A is the name of two-dimensional array and the first address of row 0 of two-dimensional array, which is equal to 1000. A[0] is the array name and the first address of the first one-dimensional array, so it is also 1000. *(a+0) or *a is equivalent to a[0] and represents the first address of element 0 of one-dimensional array A [0].

Extended data:

A[0] can be regarded as that a[0]+0 is the first address of element 0 of one-dimensional array a[0], while a[0]+ 1 is the first address of element 1 of a[0], from which it can be concluded that a[i]+j is the element J of one-dimensional array a[i].

Baidu encyclopedia-array pointer

Baidu Encyclopedia-Array Elements