fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. int* pus(int b){
  6. int top;
  7. int max;
  8. max=5;
  9.  
  10. int* a=new int[5];
  11.  
  12.  
  13. srand(time(0));
  14. int number;
  15. for(top=0;top<max;top++){
  16. number=rand()%10;
  17. a[top]=number;
  18. }
  19. return a;
  20. }
  21.  
  22. int* po(int arraypo[], int g){
  23. for(int i=g;i>=0;i--){
  24. arraypo[i]=0;
  25. }
  26. return arraypo;
  27. }
  28.  
  29.  
  30.  
  31. int main(){
  32. int st=5;
  33. int * z;
  34. z=pus(st);
  35.  
  36.  
  37.  
  38. cout<<"main: "<<pus(st)<<endl;
  39. cout<<z[0]<<" "<<z[1]<<" "<<z[2]<<" "<<z[3]<<" "<<z[4]<<endl;
  40. cout<<&z[0]<<" "<<&z[1]<<" "<<&z[2]<<" "<<&z[3]<<" "<<z[4]<<endl;
  41.  
  42.  
  43. z=po(z, st);
  44. cout<<z[0]<<" "<<z[1]<<" "<<z[2]<<" "<<z[3]<<" "<<z[4]<<" "<<endl;
  45. cout<<&z[0]<<" "<<&z[1]<<" "<<&z[2]<<" "<<&z[3]<<" "<<&z[4]<<endl;
  46.  
  47.  
  48.  
  49. delete z;
  50. return 0;
  51. }
  52.  
  53.  
  54.  
  55.  
Runtime error #stdin #stdout #stderr 0s 3476KB
stdin
Standard input is empty
stdout
main: 0x84ec020
5 5 4 1 8
0x84ec008 0x84ec00c 0x84ec010 0x84ec014 8
0 0 0 0 0 
0x84ec008 0x84ec00c 0x84ec010 0x84ec014 0x84ec018
stderr
*** Error in `./prog': free(): invalid next size (fast): 0x084ec008 ***
======= Backtrace: =========
/lib/i386-linux-gnu/i686/cmov/libc.so.6(+0x75e72)[0xb74f2e72]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(+0x76bb0)[0xb74f3bb0]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x1f)[0xb76d582f]
./prog[0x80489fc]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xf5)[0xb74968f5]
./prog[0x8048a61]
======= Memory map: ========
08048000-08049000 r-xp 00000000 09:03 16255889   /home/GdhOSa/prog
08049000-0804a000 rw-p 00000000 09:03 16255889   /home/GdhOSa/prog
084ec000-0850d000 rw-p 00000000 00:00 0          [heap]
b747b000-b747d000 rw-p 00000000 00:00 0 
b747d000-b7626000 r-xp 00000000 09:03 16394299   /lib/i386-linux-gnu/i686/cmov/libc-2.17.so
b7626000-b7627000 ---p 001a9000 09:03 16394299   /lib/i386-linux-gnu/i686/cmov/libc-2.17.so
b7627000-b7629000 r--p 001a9000 09:03 16394299   /lib/i386-linux-gnu/i686/cmov/libc-2.17.so
b7629000-b762a000 rw-p 001ab000 09:03 16394299   /lib/i386-linux-gnu/i686/cmov/libc-2.17.so
b762a000-b762d000 rw-p 00000000 00:00 0 
b762d000-b7648000 r-xp 00000000 09:03 16394343   /lib/i386-linux-gnu/libgcc_s.so.1
b7648000-b7649000 rw-p 0001a000 09:03 16394343   /lib/i386-linux-gnu/libgcc_s.so.1
b7649000-b764a000 rw-p 00000000 00:00 0 
b764a000-b768b000 r-xp 00000000 09:03 16394296   /lib/i386-linux-gnu/i686/cmov/libm-2.17.so
b768b000-b768c000 r--p 00040000 09:03 16394296   /lib/i386-linux-gnu/i686/cmov/libm-2.17.so
b768c000-b768d000 rw-p 00041000 09:03 16394296   /lib/i386-linux-gnu/i686/cmov/libm-2.17.so
b768d000-b7769000 r-xp 00000000 09:03 16679929   /usr/lib/i386-linux-gnu/libstdc++.so.6.0.18
b7769000-b776a000 ---p 000dc000 09:03 16679929   /usr/lib/i386-linux-gnu/libstdc++.so.6.0.18
b776a000-b776e000 r--p 000dc000 09:03 16679929   /usr/lib/i386-linux-gnu/libstdc++.so.6.0.18
b776e000-b776f000 rw-p 000e0000 09:03 16679929   /usr/lib/i386-linux-gnu/libstdc++.so.6.0.18
b776f000-b7776000 rw-p 00000000 00:00 0 
b7778000-b777c000 rw-p 00000000 00:00 0 
b777c000-b777d000 r-xp 00000000 00:00 0          [vdso]
b777d000-b779c000 r-xp 00000000 09:03 16394256   /lib/i386-linux-gnu/ld-2.17.so
b779c000-b779d000 r--p 0001f000 09:03 16394256   /lib/i386-linux-gnu/ld-2.17.so
b779d000-b779e000 rw-p 00020000 09:03 16394256   /lib/i386-linux-gnu/ld-2.17.so
bf965000-bf986000 rw-p 00000000 00:00 0          [stack]