Skip to content

Instantly share code, notes, and snippets.

@AtomicVar
Created April 28, 2018 06:17
Show Gist options
  • Save AtomicVar/0e87bf39f765ad094fdb098ab6264c52 to your computer and use it in GitHub Desktop.
Save AtomicVar/0e87bf39f765ad094fdb098ab6264c52 to your computer and use it in GitHub Desktop.
C++ small snippets to read a file into a single string.
#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