#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) –