C++摘要——什么时候使用std::cout,什么时候用std::cerr
2014-10-23 12:49
190 查看
What
is the difference between cout, cerr, clog of iostream header in c++? When to use which one?
stdout and stderr are different streams, even though they both refer to console output by default. Redirecting (piping) one of them (e.g. program.exe >out.txt) would not affect the other.
Generally, stdout should be used for actual program output, while all information and error messages should be printed to stderr, so that if the user redirects output to a file, information messages are still printed on the screen and not to the output file.
以前关于什么时候用cout, 什么时候用cerr有比较大的随意性质,总结一下:显式print 一定要用std::cout, 其余情况,用情况主要用std::cerr
class ClassA
{
void print()
{
std::cout<<....
}
};
相关文章推荐
- C++/GUI/Qt学习——如何在Console中使用cin、cout、cerr
- C++ 入门教程(五) 使用 std::cout 输出和数字分位符的使用
- [c++ primer plus]使用cout格式化输出
- [学习笔记][C++Primer Plus]使用cout格式化输出字符串,3q xuzhong
- C++的cout与cerr的区别
- 关于C++ 里使用Openmp并行之cout混乱输出的解决方法
- QT 中“ std::cerr ”的使用方法
- [学习笔记][C++Primer Plus]使用cout格式化输出字符串
- C++中std::tr1::function和bind 组件的使用
- QT中使用cin,cout ,cerr
- C++ std::tr1::shared_ptr使用
- 复习一下c++ std::string 的使用(转)
- c++中cerr和cout的区别
- Qt中使用cout, cin, cerr
- [C++]使用std::stringstream小心内存,适时清空缓冲。
- C++什么时候使用纯虚函数
- c++里关于cerr,clog,cout三者的区别
- 复习c++: 继承 , static, cerr , cout , clog
- c++里关于cerr,clog,cout三者的区别
- Qt中使用cout, cin, cerr