您的位置:首页 > 编程语言 > C语言/C++

[C++]普通文本文件最佳读取方式

2017-03-13 17:15 246 查看
#include <string>
#include <fstream>
#include <streambuf>
inline std::string loadFileEx(const char* path)
{
setlocale(LC_ALL,"Chinese-simplified");//设置环境中文
std::ifstream ifs(path);
setlocale(LC_ALL,"C");//还原环境
return std::string((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: