int main(){
int opt=0,x;
char ch;
do
{
printf("Enter your option: \n");
printf("1. Push()\n");
printf("2. Pop()\n");
printf("3. isEmpty()\n");
printf("4. isFull()\n");
scanf("%d",&opt);
switch(opt){
case 1: printf("Enter the value that is to be pushed:");
scanf("%d",&x);
push(x);
break;
case 2: pop();
break;
case 3: isEmpty();
break;
case 4: isFull();
break;
default: printf("You have entered a wrong option\n");
}
printf("Do you want to continue?");
scanf("%c",ch);
} while (ch=='y');
return 0;
}
do-while 循环跳过最后一个输入并退出程序。 我无法输入 ch 的值。 如果有人能够解决这个问题,那将是非常有帮助的。