早上好,
我对 C/C++ 开发人员的 Eclipse IDE 有疑问.
I have a problem with Eclipse IDE for C/C++ Developers.
我正在编写一个用于转换字符串的小工具.在某个点进行测试时 eclipse 停止提供控制台输出.例如:cout<<"test";
不显示.
I'm writting a smal tool for converting Strings. While testing on some point eclipse stopped to give console output.
e.g.:
cout<<"test";
doesn't get displayed.
但它并非无处不在......另一个例子:
But it's not every where... another example:
// File path as argument
int main(int argc, char* argv[]) {
if (argc != 2) {
cout
<< "ERROR: Wrong amount of arguments! Only one allowed...
";
cout << "
" << "Programm closed...
";
exit(1);
}
CommandConverter a(argv[1]);
cout<<"test";
a.getCommandsFromCSV();
cout<<"test2";
return 0;
}
如果缺少参数,错误消息会正确显示.但是如果参数存在并且程序继续测试输出:
The error message is displayed correctly if the argument is missing. But if the argument is there and the program continues the test outputs:
cout<<"测试";
cout<<"test2";
cout<<"test";
cout<<"test2";
不显示...
我遗漏了一些明显的东西?
are not displayed...
I am missing something obvious?
提前致谢!
你需要用换行符结束输出字符串,例如:`cout <<测试 "``.原因是标准输出被缓冲并且缓冲区在换行时被刷新.可能有一种方法可以在不输出换行符的情况下刷新 cout 缓冲区,但我不知道.可能包括对底层流缓冲区的访问(通过 rdbuf 方法).
You need to end output strings with newline, e.g.: `cout << "test "``. The reason is that the standard output is buffered and the buffer is flushed on newline. There probably exists a way to flush the cout buffer without outputting a newline, but I don't know it by heart. Probably includes access to the underlying streambuf (via the rdbuf method).
这篇关于cout 上没有控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!