fork download
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8. try {
  9. std::ifstream fs("ファイル名.txt");
  10. if (!fs)
  11. throw std::exception();
  12.  
  13. std::string line;
  14. std::getline(fs, line);
  15. if (line.empty())
  16. throw std::exception();
  17.  
  18. std::ifstream fs2(line);
  19. if (!fs2)
  20. throw std::exception();
  21.  
  22. std::getline(fs2, line);
  23. std::cout << line << std::endl;
  24.  
  25. } catch (std::exception& e) {
  26. return -1;
  27. }
  28. return 0;
  29. }
Runtime error #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty