数组元素是组成数组的基本单元。数组元素也是一种变量, 其标识方法为数组名后跟一个下标。下标表示了元素在数组中的顺序号。数组元素通常也称为下标变量。必须先定义数组, 才能使用下标变量。在C语言中只能逐个地使用下标变量,而不能一次引用整个数组。
下面来看一个打印数组元素的例子。
在c标准中,必须定义至少一个数组元素。
In standard C, at least one element of an array must be defined.
数组元素访问(不同步)代码已经在清单2中给出。
The array element access (unsynchronized) code has already been presented in Listing 2.
I've written a little for loop, which is going to iterate over all of the elements in the list.
让我们先看看这儿的代码,我已经写了一个循环语句,用来迭代处理数组中所有的元素。
These are sort of the cells, if you like, in memory that are holding the elements of the list.
记忆就像是数组中的元素,我们之前说的是,我在这里开始并且比较。
Yeah, it's kind of simple, but it gives me an ordered list of these things, And let's run it. OK.
让我们来运行运行吧,好,我会先去搜索一些数组中没有的元素,让我来试试,看-1在不在这个数组里。
应用推荐