C++摘要——什么时候使用std::cout,什么时候用std::cerr
来源:互联网 发布:淘宝全年销售额 编辑:程序博客网 时间:2024/05/17 08:13
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::cerrclass ClassA
{
void print()
{
std::cout<<....
}
};
1 0
- C++摘要——什么时候使用std::cout,什么时候用std::cerr
- std::cerr与std::cout区别
- std::cerr
- std::cerr
- C++:在C++中什么时候需要加上std::
- 使用std::copy将std::map输出到std::cout
- C++,cout和std::cout的区别
- g++std::cout的使用
- C++/GUI/Qt学习——如何在Console中使用cin、cout、cerr
- c++:: when std::stringstream std::cout encouter uint8/sint8
- extern "c" 什么时候使用
- std::cout、std::cin与cout.cin
- 使用std::cout不能输出显示
- 什么时候使用抽象类,什么时候用接口?
- std::cout和printf
- std::cout彩色输出
- C中什么时候使用static?
- 【C#】什么时候使用单例什么时候使用静态类?
- UILable转为UIImage的方法
- Openstack存储总结之:详解如何使用NFS作为Cinder的后端存储
- 移位运算符
- 从利用匿名管道实现可交互式远程超级终端cmd.exe说起
- 黑马程序员--OC--OC简介
- C++摘要——什么时候使用std::cout,什么时候用std::cerr
- DestroyWindow函数解析
- 关于协方差矩阵的概念及意义
- Linux学习笔记(六)terminal与vim配色
- Linux下一些很有用的Shell命令
- Android 源码解析之Launcher3之帮助提示的实现方案
- Java易错知识点(2) - 在读取Cookie时除了Key,Value是得不到其他信息的
- opengl入门系列- 颜色混合
- fastjson 对象字符串互转方法实例