นิยาม
std::cerr เป็น object ของ class ostream แทน standard error stream สำหรับ narrow characters (char) Corresponds to C stderr
คุณสมบัติ
- Destination: กำหนดโดย environment อาจ share กับ cout/clog
- เขียนข้อมูลได้ 2 แบบ: formatted (
<<) และ unformatted (write) - ประกาศใน
<iostream>มี external linkage และ static duration (อยู่ตลอดโปรแกรม)
ตัวอย่าง
#include <iostream>
int main() {
std::cerr << "Hello";
return 0;
}
Compile & Run
$ g++ hello.cpp $ ./a.out
ผลลัพธ์
Hello
หมายเหตุ: เนื้อหานี้ทับซ้อนกับ ID 1004083505 (cin, cout, cerr, clog)