Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
Created June 19, 2017 20:46
Show Gist options
  • Save najlepsiwebdesigner/3c66b42825f3c81e60fdf9f0025dc486 to your computer and use it in GitHub Desktop.
Save najlepsiwebdesigner/3c66b42825f3c81e60fdf9f0025dc486 to your computer and use it in GitHub Desktop.
Load whole file to std::string C++
std::ifstream t("test.txt");
std::string str;
t.seekg(0, std::ios::end);
str.reserve(t.tellg());
t.seekg(0, std::ios::beg);
str.assign((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment