cout 和cerr的区别

来源:互联网 发布:gene ontology数据库 编辑:程序博客网 时间:2024/06/06 01:24

总结了一下,主要有几点,欢迎指正。

1、cout对应于标准输出流

      cerr对应于标准错误流

2、cout可以重定向,cerr不可以。

3、cout要分配缓冲,cerr不用,所以从理论上来说,cerr输出要比cout要快。

4、cout和cerr默认都是标准输出设备:显示器.

英文表述是:

cout:
The cout object corresponds to the standard output stream. By default, this stream is associated with the standard output device, typically a monitor. The wcout object is similar but works with the wchar_t type.

cerr:
The cerr object corresponds to the standard error stream, which you can use for displaying error messages. By default, this stream is associated with the standard output device, typically a monitor, and the stream is unbuffered. This means that information is sent directly to the screen, without waiting for a buffer to fill or for a newline character. The wcerr object is similar but works with the wchar_t type.

 

原创粉丝点击