fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std; // consider removing this line in serious projects
  4.  
  5. int main() {
  6.  
  7. int *a = new int[100];
  8. a[0] = 2;
  9. a[1] = 6;
  10. a[2] = 9;
  11. a[3] = 1;
  12. a[4] = -2;
  13. //int *b = a;
  14. int *b = new int[100];
  15. memcpy(b, a, 100) ;
  16.  
  17. cout << dec << &a << endl;
  18. cout << dec << &b << endl <<endl;
  19.  
  20. cout << &a << endl;
  21. cout << &b << endl;
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5288KB
stdin
1
2
10
42
11
stdout
0x7ffff1057c48
0x7ffff1057c50

0x7ffff1057c48
0x7ffff1057c50