Water's Home

Just another Life Style

0%

Routes stream to specified buffer

Developer Command Prompt for VS 2019

cl basic_ios_rdbuf.cpp /EHsc

MSDN Source Code

#include #include #include 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; //normal
}