Export (0) Print
Expand All

basic_ios::rdbuf 

Routes stream to specified buffer.


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

Parameters

_Sb

A stream.

The first member function returns the stored stream buffer pointer.

The second member function stores _Sb in the stored stream buffer pointer and returns the previously stored value.

// 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;
}

Output

test2

Header: <ios>

Community Additions

ADD
Show:
© 2015 Microsoft