我正在制作此比萨饼订购系统代码,客户可以在其中选择比萨饼的类型和大小,并且最多可以订购10个比萨饼。问题是程序跳过了while循环中if语句中的最后一个printf()语句,该语句询问客户是否想要多个披萨。我没有复制所有功能,因为它确实很长代码,但如果问题可能在那里,那么我将其直接粘贴以查看。
我试图只写printf()语句而不使用if语句,但仍然被跳过。
int main()
{
printf("Hello! Welcome to UASKPS!\n");
printf("You can order up to 10 pizzas.\n\n");
printf("\nPress any key to start your order.\n");
_getch();
// let user order a single pizza in each loop run
char c;
nr_pizzas_ordered = 0;
do
{
system("cls");
// show pizza number
printf("\nPlease choose your pizza #%d\n", nr_pizzas_ordered + 1);
// let user choose pizza type
enum pizza_types desired_type = choose_pizza_type();
// let user choose pizza size
enum pizza_sizes desired_size = choose_pizza_size();
// store the order
all_pizza_orders[nr_pizzas_ordered].which_pizza = desired_type;
all_pizza_orders[nr_pizzas_ordered].which_size = desired_size;
// one pizza has been ordered more
nr_pizzas_ordered++;
// ask user whether he wants to order another pizza
if (nr_pizzas_ordered < 10)
{
printf("Do you want to order another pizza? (y/n)\n");
c = _getch();
}
else
c = 'n';
} while (c == 'y');
show_order_list();
printf("\n\nThank you for your order! Press any key to exit.\n");
_getch();
}