使用 Windows 和 MinGW 用 Eclipse 编写的 C++ 程序无法将输出显示到控制台视图

C++ program written in Eclipse using Windows and MinGW cannot display output to console view(使用 Windows 和 MinGW 用 Eclipse 编写的 C++ 程序无法将输出显示到控制台视图)
本文介绍了使用 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++ 程序无法将输出显示到控制台视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Eclipse gets stuck when trying to launch Android app(Eclipse 在尝试启动 Android 应用程序时卡住了)
Eclipse: Failed to initialize Monitor Thread: Unable to establish loopback connection(Eclipse:无法初始化监视器线程:无法建立环回连接)
Eclipse- JDK not found(Eclipse-找不到JDK)
How to make Eclipse behave well in the Windows 7 taskbar?(如何让 Eclipse 在 Windows 7 任务栏中表现良好?)
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)(本机方法中的致命错误:JDWP 未初始化传输,jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197))