现在的位置: 首页 > 综合 > 正文

cout 和cerr的区别

2013年08月07日 ⁄ 综合 ⁄ 共 678字 ⁄ 字号 评论关闭

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

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.

 

抱歉!评论已关闭.