问题标题:
【关于switch语句求真相switch(m)x05{x05case1:head=create();gotoA;x05case2:InsertPoint(head);gotoA;x05case3:DelPoint(head);gotoA;x05case4:print(head);gotoA;x05case5:printf("Quit?n");x05x05printf("YforYESelseforreturnn");x】
问题描述:
关于switch语句求真相
switch(m)
x05{
x05case1:head=create();gotoA;
x05case2:InsertPoint(head);gotoA;
x05case3:DelPoint(head);gotoA;
x05case4:print(head);gotoA;
x05case5:printf("Quit?n");
x05x05printf("YforYESelseforreturnn");
x05x05scanf("%c",&c);
x05x05if(c=='Y'||c=='y')
x05x05x05exit(0);
x05x05elsex05gotoA;
x05default:printf("youchosewrongdaten");gotoA;
x05}为什么这段代码没有执行scanf直接跳过scanf执行了goto
陆冬磊回答:
不知道你前面还有没有类似scanf之类的输入函数,有的话就在case5的scanf之前加一句
getchar();
沈占锋回答:
对了确实是那样能不能解释一下呢!谢谢!!