所以我有这段代码,它应该从用户那里获取坐标:
#include <stdio.h>
#include <time.h>
int main() {
int number;
char letter;
int points = 3;
while(points < 8){
printf("give me first coordinate (letter)");
scanf("%c",&letter);
printf("give me second coordinate (number)");
scanf("%d",&number);
}
}
据我所知,这应该继续从用户那里获取坐标,但它只需要一次,然后以一种非常奇怪的方式粉碎,就像它无缘无故地跳过 scanf 一样。这是我的输出:
give me first coordinate (letter)a
give me second coordinate (number)1
give me first coordinate (letter)give me second coordinate (number)12
give me first coordinate (letter)give me second coordinate (number)df
give me first coordinate (letter)give me second coordinate (number)give me first coordinate (letter)give me second coordinate (number)sss
我真的很困惑,因为这是简单的代码,我不知道是什么原因造成的。有人吗?(如果有什么不同,我的系统是山狮)