fork download
  1. #include <iostream>
  2. #include <unistd.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "Hello" << endl; // endl flushes buffer immediately
  8. execlp("ls", "ls", (char*)NULL); // correct argument list
  9.  
  10. // This will only run if execlp fails
  11. perror("execlp failed");
  12. cout << "bye" << endl;
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0.01s 5236KB
stdin
Standard input is empty
stdout
Hello
prog