-1
我希望在用户选择“VIEW”或“BID”后再次打开菜单..我将如何那样做没有无限循环?我将菜单设置为自己的功能,然后在我的“主”功能中调用它。选择一个菜单选项后,再次打印菜单..选择选项后,“do while”循环无限
int menu() {
char sel[6];
printf("Welcome to the Silent Auction!\n");
printf("Please make a selection from the following:\n");
printf("View Auction [VIEW]\n");
printf("Bid on Auction [BID]\n");
printf("Close Auction [CLOSE]\n");
return;
}
menu();
char sel[6];
scanf("%s", &sel);
do {
if (strcmp("VIEW", sel) == 0) {
...
}
if (strcmp("BID", sel) == 0) {
printf("Which auction would you like to bid on?\n");
scanf("%d", &choice);
if ...
} else {
...
} printf("How much would you like to bid?\n");
scanf("%f", &user_bid);
if ...
else
cur_bid[choice] += user_bid;
}
if (strcmp("CLOSE", sel) == 0) {
for...
}
} while (sel != "CLOSE");
return 0;
}
当用户输入“VIEW”的作品,但如果他们选择另一option..say“BID”或“关闭“,我的if语句不工作。它只是终止。 – user2251238 2013-04-07 03:01:21
确定适用于VIEW和BID。但是,当我选择“关闭”程序不通过我的if语句为此..它终止 – user2251238 2013-04-07 03:14:19
@ user2251238 ..请检查我更新的答案在哪里我使用关闭标志。 – Ganesh 2013-04-07 03:22:20