我想在用户选择“VIEW”或“BID”后再次打印菜单。如果没有无限循环,我该怎么做?我将菜单设置为自己的功能,然后在我的“主要”功能中调用它。
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;
}