# 一维数组One-Dimensional Arrays

``````
postfix-expression
[
expression
]
``````

``````// one_dimensional_arrays.c
int sum, *ptr, a[10];
int main() {
ptr = a;
sum = 4[ptr];
}
``````

``````a[b]
*(a + b)
*(b + a)
b[a]
``````

1. 将整数值 `i` 乘以定义为 `int` 项的长度的字节数。The integer value `i` is multiplied by the number of bytes defined as the length of an `int` item. `i` 的转换值表示 `i` `int` 位置。The converted value of `i` represents `i` `int` positions.

2. 此转换值将添加到原始指针值 (`line`) 以生成从 `line` 偏移 `i` `int` 个位置的地址。This converted value is added to the original pointer value (`line`) to yield an address that is offset `i` `int` positions from `line`.

3. 间接寻址运算符将应用于此新地址。The indirection operator is applied to the new address. 结果是位于该位置（直观地说，就是 `line [ i ]`）的数组元素的值。The result is the value of the array element at that position (intuitively, `line [ i ]`).

下标表达式 `line[0]` 表示行的第一个元素的值，因为 `line` 表示的地址的偏移量为 0。The subscript expression `line[0]` represents the value of the first element of line, since the offset from the address represented by `line` is 0. 同样，表达式（如 `line[5]`）引用了从行偏移 5 个位置的元素，或数组的第 6 个元素。Similarly, an expression such as `line[5]` refers to the element offset five positions from line, or the sixth element of the array.