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

时间:2014-09-24 13:47:17   收藏:0   阅读:295

每一个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
} ///:~

原文:http://www.cnblogs.com/pang1567/p/3990287.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!