将iostream中的数据全部导入到另一个iostream对象中

每一个iosteram对象都有一个streambuf对象,streambuf对象有一些成员函数。

rdbuf()函数返回了iostream对象的streambuf指针,具体示例如下:

#include "../require.h"
#include <fstream>
#include <iostream>
using namespace std;

int main() {
  ifstream in("Stype.cpp");
  assure(in, "Stype.cpp");
  cout << in.rdbuf(); // Outputs entire file
} ///:~
posted @ 2014-09-24 11:31  小菜庞  阅读(290)  评论(0编辑  收藏  举报