Initializing a recursive structure
Posted: Tue Oct 31, 2023 5:36 am
How can I initialize a recursive structure at the compilation stage?
Here is an example of the code
It doesn't work that way
Here is an example of the code
Code: Select all
struct menu_item {
char name_menu[20];
int level_menu;
bool visible;
struct menu_item *sub_menu[];
};
Code: Select all
struct menu_item main_menu[] = { {"First item", 0, true, {}},
{"Second item", 0, true, {}},
{"The third item", 0, true, { {"First sub item", 0, true, {}},
{"Second sub item", 0, true, {}},
{"The third sub item", 0, true, {}},
{"Fourth sub item", 0, true, {}}
},
{"Fourth item", 0, true, {}}
};