标准错误流(cerr)

发布时间 2023-06-08 13:40:05作者: 小孟快点跑哇

 

预定义的对象 cerr 是 iostream 类的一个实例。cerr 对象附属到标准输出设备,通常也是显示屏,但是 cerr 对象是非缓冲的,且每个流插入到 cerr 都会立即输出。

cerr 也是与流插入运算符 << 结合使用的,如下所示:

实例

#include <iostream>

 

using namespace std;

 

int main( )

{

char str[] = "Unable to read....";

 

cerr << "Error message : " << str << endl;

}

当上面的代码被编译和执行时,它会产生下列结果:

Error message : Unable to read....

 

http://www.msisle.com/