Skip to content

Instantly share code, notes, and snippets.

@takumakei
Created October 28, 2014 07:30
Show Gist options
  • Save takumakei/7c2b282f0f9dc30721b3 to your computer and use it in GitHub Desktop.
Save takumakei/7c2b282f0f9dc30721b3 to your computer and use it in GitHub Desktop.
#include <fstream>
#include <iterator>
std::vector<char> read(const std::string& name) {
std::ifstream ifs(name, std::ios::in | std::ios::binary);
if (ifs.fail()) throw std::runtime_error("file not found");
typedef std::istreambuf_iterator<char> itr;
return std::vector<char>(itr(ifs), itr());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment