我有一組結構的,定義如下:初始化嵌套結構沒有定義的所有字段
typedef struct
{
int index;
int array[10];
}
Item;
typedef struct
{
Item A;
Item B;
Item C;
}
Collection;
我要聲明Collection
類型的變量如下:
Collection collection =
{
{ 1, 0 }, /* item A */
{ 2, 0 }, /* item B */
{ 3, 0 } /* item C */
};
請問這個將三個index
變量設置爲1,2和3,同時將所有三個array[]
變量初始化爲零?
它似乎在我的編譯器上工作,但我想知道這是否是標準行爲。
這很酷。直到今天,我從未聽說過指定的初始化程序! –