ユーザが選択した後に、その選択を促すオリジナルの文(2つのprintfs)が繰り返されるように、何を修正する必要がありますか?例:whileループ内のswitch文。どのようにユーザーの選択肢を繰り返すのですか?
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);
}
}
私は自分のロジックがどこかの場所にあることを知っています。
は '破ると' switch'に 'scanf'sのすべてを交換してみてください;' – user3386109