我使用的是 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;
}
如果我运行这个控制台程序,它应该在 Eclipse 的控制台视图中显示 Hello world,但没有任何显示.
If I run this console program, it should display Hello world to Console View in Eclipse, but nothing displays.
如果我转到调试文件夹并运行 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 -osrchh.o ..srchh.cpp
..srchh.cpp: In function 'int main()':
..srchh.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?
我找到原因了,就因为我用的是64bit 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++ 程序无法将输出显示到控制台视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Eclipse 的 Visual Studio Ctrl+Tab 和 Ctrl+Shift+Tab 等效项Eclipse#39;s Visual Studio Ctrl+Tab and Ctrl+Shift+Tab Equivalent(Eclipse 的 Visual Studio Ctrl+Tab 和 Ctrl+Shift+Tab 等效项)
如何防止 Eclipse 在包资源管理器中显示打开的文How to prevent Eclipse from showing the opened file in package explorer(如何防止 Eclipse 在包资源管理器中显示打开的文件)
XML 解析器返回意外的令牌错误和空指针异常XML Parser Returning unexpected token error and null pointer exception(XML 解析器返回意外的令牌错误和空指针异常)
Java 解析 XML 文档给出“Prolog 中不允许的内容&qJava parsing XML document gives quot;Content not allowed in prolog.quot; error(Java 解析 XML 文档给出“Prolog 中不允许的内容.错误)
如何在 Eclipse 中将源附加到 Google Drive API 或“AHow to attach source to Google Drive API or `Android Private Library` in Eclipse(如何在 Eclipse 中将源附加到 Google Drive API 或“Android Pr
Lint:如何忽略“<key>"未翻译成&Lint: How to ignore quot;lt;keygt; is not translated in lt;languagegt;quot; errors?(Lint:如何忽略“lt;keygt;未翻译成lt;语言gt;错误?)