void display()
{
printf("every thing is ok");
}
void main()
{
int ch;
while(1)
{
printf("enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1: clrscr();printf("when choice is one every thing is fine");
display();
break;
case 2: clrscr();printf("when chice is two its confusing");
display();
break;
case 3: exit(0);
default: printf("enter choice as 1 or 2 or to exit enter 3");
}
}
}
當我跟蹤這個C程序並輸入選項2時,它調用case 1模塊的顯示功能。我不明白。請回答一個解釋。我很困惑。c switch語句
對我來說沒問題。當你輸入1時會發生什麼?你是什麼意思「它稱爲情況1塊的顯示功能」? Display()在您提供的代碼中從案例1和案例2中調用 – 2010-12-01 18:51:18
您的預期輸出是什麼?您看到了什麼? – casablanca 2010-12-01 18:51:19