c++ 读文本文件
时间:2014-05-19 21:27:01
收藏:0
阅读:321
1.
std::ifstream t("example.txt");
std::string str((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
2
void readfile(const std::string &filepath,std::string &buffer){
std::ifstream fin(filepath.c_str());
getline(fin, buffer, char(-1));
fin.close();
}
3
void readfile(const std::string &filepath,std::string &buffer){
std::ifstream fin(filepath.c_str());
stringstream strStream;
strStream << fin.rdbuf();
buffer= strStream.str();
fin.close();
}
评论(0)