C的数组
/* 数组指定元素初始化(C99) */
#include <stdio.h>
int main()
{
int days[10] = {1, 2, 3, [5] = 5, 6, 7, [1] = 8}; //对同一元素多次初始化,以最后一次有效
int i = 0, n = sizeof(days) / sizeof(days[0]);
for (i = 0; i < n; i++)
{
printf("%d ", days[i]);
}
return 0;
}
// 运行结果:
1 8 3 0 0 5 6 7 0 0