首先,还有一个问题是同一个标题,但提供的解决方案并不适合我。 Other questionscanf不在eclipse中的调试模式下输入?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a, b, c;
fflush(stdout);//suggested solution in other question
scanf("%d%d%d", &a, &b, &c);
printf("Values entered: %d %d %d\n", a, b, c);
return 0;
}
当我正常运行它时,代码工作正常。
输出
1 2 3
Values entered: 1 2 3
但是,当我在调试模式下运行没有打印。当我将鼠标悬停在变量上时,它们具有这些值。
一个:56
B:6422420
C:6422420
另一种解决方案建议是把这个代码在主方法的开始。
int ch;
while ((ch = getchar()) != '\n' && ch != EOF); //suggested solution #1
这篇文章中提出的两种解决方案都不适合我。我分别尝试了他们。
编辑
操作系统:Windows 10
编译:MinGW的
什么编译器(Eclipse是*不是*编译器)以及您正在使用什么操作系统? –
我建议在命令行上编译。 Eclipse只是向你隐瞒事情。 –
C和C++是不同的语言,在询问您的程序时不会同时指定。 –