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

前端之家收集整理的这篇文章主要介绍了使用Windows和MinGW在Eclipse中编写的C程序无法显示输出到控制台视图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Windows 7 64位.

我安装了eclipse版本3.6.2,cdt和MinGW.我在Eclipse中有一个C控制台程序,如下所示:

#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,但不显示任何内容.

如果我去调试文件夹并运行exe,它会打印到控制台.

如果我犯了一些语法错误,那么Eclipse Console View会显示一些东西,比如:

**** 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控制台程序显示输出

我发现这个网站的解决方法
http://www.eclipse.org/forums/index.php?=42e862594001fa4469bbc834885d545f&t=msg&th=197552

在那个链接中,看看“没有真实姓名”的答复.

如果链接断开,这里是内容

Environment: jdk1.6u18 64bit + Eclipse Helios 64bit + win7 64bit

No console output at "Run",but output correctly at "Debug".

The following method worked for me:

1.  Goto Project->Properties->Run/Debug Settings,choose the .exe file 
and press "Edit"

2.  In the "Environment" tag,press "New",set it as: 
    "Name:PATH"
    "Value:C:\MinGW\bin"

In fact,I have already set "C:\MinGW\bin" in windows PATH environment 
variable,but it seemed to not work.
原文链接:https://www.f2er.com/windows/371542.html

猜你在找的Windows相关文章