次の方法で共有


cerr

<cstdio>で宣言されたオブジェクト stderrに関連付けられているストリームのバッファーへのオブジェクトの cerr のコントロールの出力します。

extern ostream cerr;

戻り値

ostream オブジェクト。

解説

オブジェクトは、バイト ストリームとして標準エラー出力にバッファリングされない挿入を制御します。一度オブジェクトが構築されます cerr.、式フラグ&unitbuf は非ゼロと cerr.tie() == &coutです。

使用例

// iostream_cerr.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

using namespace std;

void TestWide( ) 
{
   int i = 0;
   wcout << L"Enter a number: ";
   wcin >> i;
   wcerr << L"test for wcerr" << endl;
   wclog << L"test for wclog" << endl;   
}

int main( ) 
{
   int i = 0;
   cout << "Enter a number: ";
   cin >> i;
   cerr << "test for cerr" << endl;
   clog << "test for clog" << endl;
   TestWide( );
}

入力

3
1

出力例

Enter a number: 3
test for cerr
test for clog
Enter a number: 1
test for wcerr
test for wclog

必要条件

ヘッダー: <iostream>

名前空間: std

参照

関連項目

ostream

入出力ストリームのプログラミング

入出力ストリームの規則