fork(1) download
  1. #include <string>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <streambuf>
  5.  
  6. using namespace std;
  7.  
  8. void show(const char *name)
  9. {
  10. cout << "=== " << name << " ===" << endl;
  11. ifstream f(name);
  12. string str((istreambuf_iterator<char>(f)), istreambuf_iterator<char>());
  13. cout << str << endl;
  14. cout << "========\n" << endl;
  15. }
  16.  
  17. int main()
  18. {
  19. show(__FILE__);
  20. show("./" __FILE__);
  21. show("../" __FILE__);
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
=== prog.cpp ===

========

=== ./prog.cpp ===

========

=== ../prog.cpp ===

========