使用std::streambuf_iterator讀取文件
#include <fstream>
#include <string>
using namespace std;
void main()
{
?ifstream inputFile("Data.txt");
?if(!inputFile.is_open())
???????????return;
//這條語句在VC6下編譯報錯,VC6對模板支持不夠
?string str((istreambuf_iterator<char>(inputFile)), istreambuf_iterator<char>());
?inputFile.close();
}
posted on 2006-11-04 16:54 永遇樂 閱讀(1411) 評論(0) 編輯 收藏 引用 所屬分類: STL & Boost