Skip to content

Instantly share code, notes, and snippets.

@xkyii
Created December 5, 2011 05:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
read
std::ifstream in("some.file");
std::istreambuf_iterator<char> beg(in), end;
std::string str(beg, end);
// or
std::ifstream in("some.file");
std::ostringstream tmp;
tmp << in.rdbuf();
std::string str = tmp.str();
// 读取文件并按行遍历
std::ifstream in("some.file");
std::string line;
while(std::getline(in,line))
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment