【发布时间】:2017-03-12 16:23:21
【问题描述】:
如何在 switch 语句中要求用户输入将在 c 中生成另一个 switch,我尝试了这个但我的程序崩溃了。
#include <stdio.h>
#include <stdlib.h>
int main()
{
char choise1, choise2;
printf("Starting menu:\n a -> Start\n");
choise1 = getchar();
switch(choise1){
case 'a':
printf("\n a -> New Game\n b -> Load Game");
choise2 = getchar();
switch(choise2){
case 'a':
printf("Start new game.");
break;
case 'b':
printf("Loading game.");
break;
default:
printf("This is a wrong input.");
}
break;
default:
printf("This is a wrong input.");
}
return 0;
}
【问题讨论】: