basic_ios::rdbuf
Routes stream to specified buffer.
basic_streambuf<Elem, Traits> *rdbuf( ) const;
basic_streambuf<Elem, Traits> *rdbuf(
basic_streambuf<Elem, Traits> *_Sb
);
매개 변수
- _Sb
스트림입니다.
설명
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;
}
요구 사항
Header: <ios>
네임스페이스: std