fork download
  1. static std::vector<char> readFile(const char* filename)
  2. {
  3. std::ifstream file;
  4. file.open(filename, std::ios::in);
  5. if(!file.good())
  6. throw std::runtime_error("Cannot open input file.");
  7.  
  8. file >> std::noskipws;
  9. std::vector<char> result;
  10. std::copy(std::istream_iterator<char>(file), std::istream_iterator<char>(), std::back_inserter(result));
  11. result.push_back('\0');
  12. if(!file.eof() && file.fail())
  13. throw std::runtime_error("I/O error when reading the input file.");
  14. return result;
  15. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty