Guest User

Untitled

a guest
May 27th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int* foo (int array1[],int size1,int array2[],int size2, int *newarrsize)
  9. {
  10.     int i=0;
  11.     int* newarr = new int[size1+size2];
  12.     for (i=0; i<size1; i++)
  13.     {
  14.         *(newarr+i) = array1[i];
  15.     }
  16.     for (i=0; i<size2; i++)
  17.     {
  18.         *(newarr+size1+i) = array2[i];
  19.     }
  20.    
  21.     *newarrsize = sizeof(newarr) / 4;
  22.     return newarr;
  23. }
  24.  
  25.     void main()
  26. {
  27.     int array1[] ={1,2,3,4,5};
  28.     int array2[] ={6,7,8,9,10};
  29.     int newarrsize = 0;
  30.    
  31.     int size1 = sizeof(array1) / sizeof(array1[0]);
  32.     int size2 = sizeof(array2) / sizeof(array2[0]);
  33.     int *new_address;
  34.     new_address = foo(array1,size1,array2,size2, &newarrsize);
  35.    
  36.     for (int i=0; i < size1+size2; i++)
  37.         cout << *(new_address+i);
  38. }
Add Comment
Please, Sign In to add comment