#include <stdio.h>
int main()
{
char loop='y';
while(loop != 'n') {
printf("loop? ");
scanf("%c", &loop);
if(loop != 'y') {
loop='n';
}
}
return 0;
}
如果我键入'y',他重新启动while循环但第二次忽略scanf并在此之后结束循环。谁能帮忙?while循环第二次忽略scanf
看看这篇文章:http://www.gidnetwork.com/b-60.html –
可能重复的[第二个scanf不工作](http://stackoverflow.com/questions/4023643/second-scanf - 不工作) – AShelly
[Scanf在C语言中跳过while循环]的可能重复(http://stackoverflow.com/questions/1669821/scanf-skips-every-other-while-loop-in-c) –