Created
April 28, 2018 06:17
-
-
Save ZJUGuoShuai/0e87bf39f765ad094fdb098ab6264c52 to your computer and use it in GitHub Desktop.
C++ small snippets to read a file into a single string.
This file contains hidden or 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
#include <iostream> | |
#include <sstream> | |
#include <fstream> | |
std::string readFileToStr(std::string file) | |
{ | |
std::ifstream input(file); | |
std::stringstream sstr; | |
while(input >> sstr.rdbuf()); | |
return sstr.str(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment