#include <iostream>
#include <fstream>
using namespace std;
ofstream file( "rdbuf.txt" );
streambuf *x = cout.rdbuf( file.rdbuf( ) );
cout << "test" << endl;
cout << "test2" << endl;
cout.rdbuf(x);
C++ 文件写入
最新推荐文章于 2024-05-18 10:02:23 发布
#include <iostream>
#include <fstream>
using namespace std;
ofstream file( "rdbuf.txt" );
streambuf *x = cout.rdbuf( file.rdbuf( ) );
cout << "test" << endl;
cout << "test2" << endl;
cout.rdbuf(x);