fork(2) download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. std::vector<short> randVect()
  8. {
  9. std::vector<short> rV(0);
  10. for(int i=0; i<100; i++)
  11. {
  12. rV.push_back(rand());
  13. }
  14. return rV;
  15. }
  16.  
  17. int someCondition=1;
  18.  
  19.  
  20. short* test()
  21. {
  22. std::vector<short> tV(0);
  23. std::vector<short> tV2=randVect();
  24. if(someCondition==1){
  25. short *tmp=new short[2];
  26. cout << "test() says : " << tmp << endl;
  27. return tmp;
  28. }else if(someCondition==2){
  29. short *tmp=new short[4];
  30. cout << "test() says : " << tmp << endl;
  31. return tmp;
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37. cout << "Hello world!" << endl;
  38. cout << "main() says : " << test() << endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
Hello world!
test() says : 0x9f6b008
main() says : 0x9f6b008