0
我需要修改什么,以便在用户做出选择后,提示用户选择的原始语句(两个printfs)会不断重复?例如:在while循环中切换语句。我将如何重复用户的选择?
while(1) {
printf("What would you like to do next? \n");
printf("\tC to create more\n\tD to display\n\tI to insert at beginning\n\tN to exit\n");
scanf(" %c", &response);
switch(response) {
case 'C' : create(); scanf(" %c", &response);
case 'D' : display(); scanf(" %c", &response);
case 'I' : insert_at_beg(); scanf(" %c", &response);
case 'N': exit(0);
default : printf("Invaild choice. Bye\n"); exit(0);
}
}
我知道我的逻辑遍布某些地方。
用'打破替换所有'scanf's在'之开关;' – user3386109