任何人都可以告诉我为什么printf语句被执行2次?
do {
printf("\n Enter the choice: a to add, d to display, q to exit: ");
scanf("%c",&choice);
switch(choice) {
case 'a':
addData();
break;
case 'd':
display();
break;
}
} while (choice != 'q');
我期待以下内容:
Enter the choice: a to add, d to display, q to exit: a
Enter the choice: a to add, d to display, q to exit: d
但我得到以下内容:
Enter the choice: a to add, d to display, q to exit: a
Enter the choice: a to add, d to display, q to exit:
Enter the choice: a to add, d to display, q to exit: d
任何人都可以让我知道,中间线背后的问题是什么?
谢谢, Meghdeep