我在函数中有以下代码
char MenuOptions[7][200];
strcpy(MenuOptions[0], "Create New / Modify Existing Customer");
strcpy(MenuOptions[1], "Create New / Modify Existing Product");
strcpy(MenuOptions[2], "List All customers");
strcpy(MenuOptions[3], "List All Products");
strcpy(MenuOptions[4], "Batch Update of New Stock");
strcpy(MenuOptions[5], "Create Customer Order");
strcpy(MenuOptions[6], "View Last Order for Customer");
switch (displayMenu("Main Menu", MenuOptions, 7, TRUE)) {
etc....
和
char displayMenu(char *name, char *options[], int menuLength,
enBoolean QuitEnabled) {
int i;
printf("%s: \n", name);
for (i = 0; i < menuLength; i++) {
printf("\t %d %s.\n", (i + 1), options[i]);
}
if (QuitEnabled == TRUE)
printf("\t Q. Quit\n");
etc
但是,一旦输入了 displayMenu 方法,MenuOptions 数组似乎就从内存中丢失了。我尝试通过 eclipse 中的表达式窗口查看 options[i] 是什么,它说它“超出范围”作为一个值