fork download
  1. #include <iostream> //just for std::cin.get();
  2. #include <ifstream>
  3. #include <string>
  4.  
  5. int main()
  6. {
  7. std::string full_content, filename{ "data.txt" };
  8. std::ifstream ifs(filename, std::ios::binary | std::ios::ate);
  9. const unsigned int n = static_cast<unsigned int>(ifs.tellg());
  10.  
  11. full_content.resize(n);
  12. ifs.seekg(0, std::ios::beg);
  13. ifs.read(&full_content[0], static_cast<std::streamsize>(n));
  14.  
  15. std::cin.get(); //pause
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:20: fatal error: ifstream: No such file or directory
compilation terminated.
stdout
Standard output is empty