C++ program written in Eclipse using Windows and MinGW cannot display output to console view(使用 Windows 和 MinGW 用 Eclipse 编写的 C++ 程序无法将输出显示到控制台视图)
问题描述
我使用的是 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++ 程序无法将输出显示到控制台视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Windows 和 MinGW 用 Eclipse 编写的 C++ 程序无法
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
