c - 要循环只执行scanf函数后的人 [英] C - for loop only execute ones after scanf
本文介绍了c - 要循环只执行scanf函数后的人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的为
循环只运行一次,进入我的回答与 scanf函数
之后,为
循环终止。我不知道为什么?
的for(int i = 0;我小于10;我++){
焦炭的答案;
gotoxy(32,10); //自制功能(利用开发的C ++)去坐标
star_vowels(易[I]);
gotoxy(30,18);
的printf(答:);
scanf函数(%S,&安培;回答);
}
解决方案
在答案变量定义为字符,所以你应该改变scanf函数功能的格式字符串:
scanf函数(%C,&安培;回答);
The for
loop runs only once, after entering my answer with scanf
, the for
loop terminates. I have no idea why?
for(int i = 0; i < 10; i++){
char answer;
gotoxy(32,10); //self-made function(using Dev C++) to go to a coordinate
star_vowels(easy[i]);
gotoxy(30,18);
printf("ANSWER: ");
scanf("%s", &answer);
}
解决方案
The answer variable is defined as character so you should change the format string of the scanf function:
scanf("%c",&answer);
这篇关于c - 要循环只执行scanf函数后的人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文