fork 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.  
  21. system("pwd");
  22. system("ls -laR /home");
  23. system("ls -la /tmp");
  24. system("ls -la ./");
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
=== prog.cpp ===

========

/home/Lb1nhf
/home:
total 20
drwxr-xr-x  5 root root 4096 Jan  8 13:59 .
drwxr-xr-x 24 root root 4096 Feb  7  2017 ..
drwxr-x---  2 root 1000 4096 Jan  8 13:59 B3jbvz
drwxr-x---  2 root 1000 4096 Jan  8 13:59 Lb1nhf
drwxrwx---  2 root 1000 4096 Jan  8 13:59 mkgHPB

/home/B3jbvz:
total 16
drwxr-x--- 2 root 1000 4096 Jan  8 13:59 .
drwxr-xr-x 5 root root 4096 Jan  8 13:59 ..
-rwxr-xr-x 1 root root 6328 Jan  8 13:59 prog

/home/Lb1nhf:
total 24
drwxr-x--- 2 root 1000  4096 Jan  8 13:59 .
drwxr-xr-x 5 root root  4096 Jan  8 13:59 ..
-rwxr-xr-x 1 root root 14856 Jan  8 13:59 prog

/home/mkgHPB:
total 12
drwxrwx--- 2 root  1000 4096 Jan  8 13:59 .
drwxr-xr-x 5 root  root 4096 Jan  8 13:59 ..
-rw------- 1 20113 1000    0 Jan  8 13:59 ccgHWOGv.o
-rw-rw-r-- 1 root  root  602 Jan  8 13:59 prog.cpp
total 20024
drwxrwxrwx  8 root  root 20463616 Jan  8 13:59 .
drwxr-xr-x 24 root  root     4096 Feb  7  2017 ..
drwx------  2 root  root     4096 Jan  8 13:59 0nr5Jz
drwxrwxr-x  2  1001 1000     4096 Jan  8 13:59 8a4c2a92-a84c-4e82-ad89-3bfc4d9c5dc0
drwxrwxrwt  2 root  root       40 Jan  8 13:59 8be3fc26-953b-4da6-827b-630b1d8f7c3b
drwxrwx---  2 root  1000       40 Jan  8 13:59 8Q4u9d
drwx------  3 20044 1000     4096 Jun 24  2018 GNUstepSecure20044
drwx------  3 20084 1000     4096 Jun  7  2018 GNUstepSecure20084
prw-rw-r--  1 20056 1000        0 Dec 18 19:02 myfifo
-rw-rw-r--  1 20039 1000      400 Dec 15 13:30 test.bin
-rw-rw-r--  1 20127 1000       10 Dec 28 13:57 teste
-rw-rw-r--  1 20037 1000       60 Jan  8 07:36 test.txt
-rw-rw-r--  1 20066 1000       60 Jan  8 07:44 tet.txt
total 24
drwxr-x--- 2 root 1000  4096 Jan  8 13:59 .
drwxr-xr-x 5 root root  4096 Jan  8 13:59 ..
-rwxr-xr-x 1 root root 14856 Jan  8 13:59 prog