No console output on cout(cout 上没有控制台输出)
问题描述
早上好,
我对 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 上没有控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cout 上没有控制台输出
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
