次の方法で共有


basic_ios::rdbuf

指定したバッファーへのルーティングのストリーム。

basic_streambuf<Elem, Traits> *rdbuf( ) const;
basic_streambuf<Elem, Traits> *rdbuf( 
    basic_streambuf<Elem, Traits> *_Sb
);

パラメーター

  • _Sb
    ストリーム。

解説

一つ目のメンバー関数は、格納されているストリーム バッファーへのポインターを返します。

2 つ目のメンバー関数は、格納されているストリーム バッファー ポインターで _Sb を保存し、格納されている値を返します。

使用例

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

int main( ) 
{
   using namespace std;
   ofstream file( "rdbuf.txt" );
   streambuf *x = cout.rdbuf( file.rdbuf( ) );
   cout << "test" << endl;   // Goes to file
   cout.rdbuf(x);
   cout << "test2" << endl;
}
  

必要条件

ヘッダー: <ios>

名前空間: std

参照

関連項目

basic_ios クラス

iostream プログラミング

iostreams の規則