Created
June 19, 2017 20:46
-
-
Save najlepsiwebdesigner/3c66b42825f3c81e60fdf9f0025dc486 to your computer and use it in GitHub Desktop.
Load whole file to std::string C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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