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(...).
我刚开始用Ncurses编程,但是,当我启动这个程序时,我得到了“Segmentation fault(core dump)”。当我调用函数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.
提前致谢。 PS:对不起,如果我没有发表评论。
1 个解决方案
#1
2
You are not filling mainMenu_items
correctly inside the loop.
您没有在循环内正确填充mainMenu_items。
You are doing
你在做
mainMenu_items = ...
but you probably meant
但你可能意味着
mainMenu_items[i] = ...
#1
2
You are not filling mainMenu_items
correctly inside the loop.
您没有在循环内正确填充mainMenu_items。
You are doing
你在做
mainMenu_items = ...
but you probably meant
但你可能意味着
mainMenu_items[i] = ...