fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4.  
  5. std::string Slurp(std::string f)
  6. {
  7. std::ifstream ifs(f.c_str());
  8. std::stringstream sstr;
  9. sstr << ifs.rdbuf();
  10. std::string code = sstr.str();
  11. return code;
  12. }
  13.  
  14. int main()
  15. {
  16. std::string text = Slurp("test.cpp");
  17. std::cout << text;
  18. return 0;
  19. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty