我正在尝试do-while条件,而在其中有另一个,我在#34中有问题;你想继续吗?",它跳过它..有什么不对我的代码?
do {
printf("\nEnter the start value:");
scanf("%d", &start_value);
printf("\nEnter the end value:");
scanf("%d", &end value);
printf("\nEnter the interval value:");
scanf("%d", &interval_value);
while (start_value <= end_value) {
printf("%d ", start_value);
start_value = start_value + interval_value;
}
printf("\nDo you want to continue?");
scanf("%c", &answer);
} while (answer != 'N' || answer != 'n');
答案 0 :(得分:3)
您的条件声明
while(answer != 'N' || answer != 'n');
总是true
。我建议
while(answer != 'N' && answer != 'n');
(除了@SouravGhosh上面的第一条评论,它清除输入缓冲区中的newline
左侧)