One of the main use cases of arrays is to be used along with loops.
数组的主要用例之一是与循环一起使用。
Given an array like this:
给定这样的数组:
const int SIZE = 5;
int prices[SIZE] = { 1, 2, 3, 4, 5 };
You can iterate over each element using a for loop in this way:
您可以按以下方式使用for循环遍历每个元素:
for (int i = 0; i < SIZE; i++) {
printf("%u\n", prices[i]);
}