fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void f()
  5. {
  6. int* arr = new int[3];
  7. cout << "I will now delete array in function\n";
  8. delete[] arr;
  9. }
  10.  
  11. int main()
  12. {
  13. int* arr = new int[3];
  14.  
  15. f();
  16.  
  17. cout << "I will now delete array in main()\n";
  18. delete[] arr;
  19.  
  20. cout << "Everything's ok.\n";
  21. return 0;
  22. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
I will now delete array in function
I will now delete array in main()
Everything's ok.