使用Windows和MinGW在Eclipse中编写的C ++程序无法向控制台视图显示输出 [英] C++ program written in Eclipse using Windows and MinGW cannot display output to console view
问题描述
我使用的是Windows 7 64位。
I'm using Windows 7 64bit.
我安装了eclipse 3.6.2,cdt和MinGW。我在Eclipse中有一个C ++控制台程序,如下所示:
I installed eclipse version 3.6.2, cdt, and MinGW. I have a C++ console program in Eclipse as follows:
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
setbuf(stdout, NULL);
for (int i = 0; i < 10000000; i++) {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
}
int val;
cin >> val;
return 0;
}
如果我运行这个控制台程序,它应该显示
If I run this console program, it should display Hello world
to Console View in Eclipse, but nothing displays.
如果我转到debug文件夹并运行exe,它会打印到
If I go to the debug folder and run the exe, it does print to the console.
如果我有一些语法错误,那么Eclipse控制台视图将显示如下内容:
If I make some syntax mistake, then the Eclipse Console View will show something, such as:
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hh.o ..\src\hh.cpp
..\src\hh.cpp: In function 'int main()':
..\src\hh.cpp:17:3: error: expected ';' before 'return'
Build error occurred, build is stopped
Time consumed: 255 ms.
为什么在Eclipse控制台视图中没有显示任何内容,以及如何让我的C ++控制台程序显示输出?
Why is nothing showing in the Eclipse console view and how can I make my C++ console program display output?
推荐答案
我找到原因,只是因为我使用的是64位eclipse!
I find the reason, just because I'm using 64bit eclipse!
我转向32位eclipse,同样的代码工作正常。
I turn to 32 bit eclipse, the same code works fine.
这篇关于使用Windows和MinGW在Eclipse中编写的C ++程序无法向控制台视图显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!