我无法看到我在调试期间写入控制台(Eclipse C ++)的内容
for (int i=0; i<5; i++) {
cout << i;
}
如何在调试时在控制台上配置Eclipse写入?
答案 0 :(得分:1)
相关的Eclipse CDT : running C++ program not showing anything in the console! Why? Eclipse CDT : running C++ program not showing anything in the console! Why? C++ program written in Eclipse using Windows and MinGW cannot display output to console view如果您使用的是胜利x64,则可能是个错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=236330
答案 1 :(得分:0)
它不是Eclispe(它是一个编辑器,而不是编译器;可能你的Eclipse会使用g++
程序运行像GCC这样的编译器;然后你运行已编译的可执行文件)。
如果您没有看到预期的输出,可能是因为您的输出保持buffered。
你可以试试std::flush操纵者。
for (int i=0; i <5; i++)
std::cout << i << std::flush;
请参阅this question以及那里的几个好答案。
您可能会阅读有关std::endl操纵器的更多信息。我建议不时做std::cout << std::endl
。
您可以考虑使用std::clog输出流。