执行std :: cout不会在运行模式下打印,而是在调试模式下打印

时间:2015-09-18 06:37:49

标签: c++ eclipse c++11 mingw

考虑到这段代码,这非常奇怪:

#include <iostream>
#include "DummySubject.h"
#include "Shop.h"

int main(int argc, char* argv[])
{
    std::cout << "1234567" << std::endl;
    // more code 
    return 0;
}

当我在运行模式下执行此代码时,此代码不会在控制台上打印任何内容,但是当我在调试模式下执行它时,cout会在屏幕上打印1234567

知道问题可能是什么?

我甚至使用过std::flush但它没有帮助。

编辑:

没有包含:

#include <iostream>
//#include "DummySubject.h"
//#include "Shop.h"

int main(int argc, char* argv[])
{
    std::cout << "1234567" << std::endl;

//  DummySubject mySubject;
//
//    // We have four shops wanting to keep updated price set by mySubject owner
//    Shop shop1("Shop 1");
//    Shop shop2("Shop 2");
//
//    mySubject.Attach(&shop1);
//    mySubject.Attach(&shop2);
//
//    //Now lets try changing the products price, this should update the shops automatically
//    mySubject.ChangePrice(23.0f);
//
//    //Now shop2 is not interested in new prices so they unsubscribe
//    mySubject.Detach(&shop2);
//
//    //Now lets try changing the products price again
//    mySubject.ChangePrice(26.0f);


    return 0;
}

仍然无效。

1 个答案:

答案 0 :(得分:-1)

以下是答案:

取自here

  

这适用于我在Windows 7上使用64位Eclipse安装   MinGW的:

     

右键单击您的项目。选择“属性”。

     

选择新左侧的“运行/调试设置”属性   窗口。

     

在右侧窗口中,单击您的可执行文件以突出显示(即 -   Test.exe)并单击“编辑”。

     

在“环境”标签中,点击“新建”

     

名称:PATH值:MinGW bin目录的路径。 (对我来说这是:   C:\ devcore \ MinGW \ bin)

     

在所有窗口上单击“确定”关闭。

     

再试一次,它应该将输出打印到屏幕上。

相关问题