我有以下代碼,我想終止while循環,如果除1 & 2
以外的任何鍵被按下。但只有do
執行一次。而不是while
。爲什麼我的while condition
總是錯誤的。請指導:做,而不是執行,意外終止
char a;
do
{
printf("To Enter the Employee sales press 1 \n");
printf("To Add more items press 2 \n ");
printf("Press any key to Terminate \n\n");
scanf("%c", &a);
if (a == '1')
{
printf("1 is presed ");
}
else if(a == '2')
{
int c;
printf("entre Value:");
scanf("%d",&c);
printf("\n");
addItem(&myArray, &size, c);
printitems(myArray, size);
}
}while(a == '1' || a == '2');
編輯很抱歉,那是在單QOUT。我忘了把最新的代碼。即使使用qoutes,它也不會運行。
一個==「1」 ...(單引號)? – darshandzend