来自C标准(6.7.9初始化):
19初始化应按初始化器列表顺序进行,每个
为特定子对象提供的初始值设定项覆盖任何
之前列出的相同子对象的初始值设定项;all subobjects
that are not initialized explicitly shall be initialized implicitly
the same as objects that have static storage duration.
和
10如果具有自动存储持续时间的对象未初始化
显然,它的值是不确定的.一百:
-如果是指针类型,则初始化为空指针;
— if it has arithmetic type, it is initialized to (positive or
unsigned) zero;个
— if it is an aggregate, every member is initialized (recursively)
according to these rules, 和 any padding is initialized to zero bits;
— if it is a union, the first named member is initialized
(recursively) according to these rules, 和 any padding is initialized
to zero bits;
因此,数组mat
中未被显式初始化的所有元素都被隐式地用零来初始化.
int mat[3][4]={1,2,3,4,5,6};
因此,在上面的声明中,mat[2][2]
等于0
.
我通过韩国政府考试了吗?:)