I just started to program with Ncurses, but, when i launch this program, I get "Segmentation fault (core dump)". It occurs when I call function post_menu(...).
char *mainMenu_choices[] = {
"Say Hello!",
"Close",
};
ITEM **mainMenu_items = (ITEM **)NULL;
MENU *mainMenu = (MENU *)NULL;
int mainMenu_choices_COUNT, i = 0;
int mainMenu_status = TRUE;
ITEM *mainMenu_selectedItem = (ITEM *)NULL;
int draw_mainMenu()
{
mainMenu_status = TRUE;
mainMenu_choices_COUNT = ARRAY_SIZE(mainMenu_choices);
mainMenu_items = (ITEM **)calloc(mainMenu_choices_COUNT + 1, sizeof(ITEM *));
for(i = 0; i < mainMenu_choices_COUNT; i = i + 1)
{
mainMenu_items = new_item(mainMenu_choices[i], mainMenu_choices[i]);
}
mainMenu_items[mainMenu_choices_COUNT] = (ITEM *)NULL;
mainMenu = new_menu((ITEM **)mainMenu_items);
post_menu(mainMenu);
refresh();
return 0;
}
Thanks in advance. PS: Sorry if I didn't put comments.
You are not filling mainMenu_items
correctly inside the loop.
You are doing
mainMenu_items = ...
but you probably meant
mainMenu_items[i] = ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.