的結構結構的數組我有這些結構:C:在陣列
struct menu_item{
int id;
char *text;
};
struct menu_tab{
char *label;
unsigned char item_count;
struct menu_item *items;
};
struct menu_page{
char *label;
unsigned char tab_count;
struct menu_tab *tabs;
};
struct Tmenu{
unsigned char page_count;
struct menu_page *pages;
};
而且我想定義整個菜單系統:
struct Tmenu menu_test = {
2,
{
"F1",
2,
{
{
"File",
8,
{
{1, "text 1"},
{2, "text2"},
{3, "text3333333"},
{4, "text4"},
{5, "Hello"},
{6, "42"},
{7, "world"},
{8, "!!!!!!!!"}
}
},
{
"File2",
3,
{
{11, "file2 text 1"},
{12, "blah"},
{13, "..."}
}
}
}
},
{
"F2",
1,
{
{
"File3",
5,
{
{151, "The Answer To Life"},
{152, "The Universe"},
{153, "and everything"},
{154, "iiiiiiiiiiiiiiiis"},
{42, "Fourty-Two"}
}
}
}
}
};
但是,當我嘗試編譯,我收到extra brace group at end of initializer
錯誤消息。
我嘗試了許多不同的方法來做到這一點,但沒有一個成功的。那麼是否可以在C中使用複雜的結構呢?
你剛剛來自PHP嗎? :-) –
不是,來自PHP,來自JSON :) – balping