[英]Eclipse CDT with C running errors
so I've decided to install Eclipse to use for my C programming. 因此,我决定安装Eclipse来进行C编程。 I wanted to write a small program, just to test that everything works, however it seems that Eclipse won't let me scan in any C inputs.
我想编写一个小程序,只是为了测试一切正常,但是似乎Eclipse不允许我扫描任何C输入。 For any other program, that requires no input, it works fine but it seems for some reason Eclipse won't run any program that requires a use to input.
对于任何其他不需要输入的程序,它都可以正常工作,但是由于某些原因,Eclipse不会运行任何需要使用输入的程序。 I'm running the programs by going to Run->Run As-> Local C/C++ Applications.
我正在通过运行->运行方式->本地C / C ++应用程序来运行程序。 I've also tried running these programs through the command line, and they turn out fine.
我也尝试通过命令行运行这些程序,结果证明效果很好。 Any ideas?
有任何想法吗?
Code: 码:
#include <stdio.h>
int main(void) {
int length, width, height, volume, weight;
printf("Enter the length of box: ");
scanf("%d", &length);
printf("Enter the height of box: ");
scanf("%d", &height);
printf("Enter the width of box: ");
scanf("%d", &width);
volume = length * width * height;
weight = (volume+165)/166;
printf("Volume(cubic inches) %d\n", volume);
printf("Dimensional weight(pounds): %d\n", weight);
return 0;
}
Installed Packages: 已安装的软件包:
After I try to run these programs, nothing appears in the console window, but after I press stop this is what comes out: 在尝试运行这些程序之后,控制台窗口中什么也没有出现,但是在我按下Stop之后,结果如下:
Here's a better pic: http://i.imgur.com/zgV1r.png 这是一个更好的图片: http : //i.imgur.com/zgV1r.png
Try adding an fflush(stdout)
after each of your printf() calls as suggested here . 尝试按照此处的建议在每个printf()调用之后添加
fflush(stdout)
。
Here is some more discussion of why fflush is required . 这是为什么需要使用fflush的更多讨论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.