fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct myArray
  5. {
  6. int array[10];
  7. };
  8.  
  9. myArray uni(int *a,int *b)
  10. {
  11. myArray c;
  12. int i=0;
  13. while(a[i]!=-1)
  14. {
  15. c.array[i]=a[i];
  16. i++;
  17. }
  18. for(;i<10;i++)
  19. c.array[i]=b[i-5];
  20. return c;
  21. }
  22.  
  23. int main()
  24. {
  25. int a[10]={1,3,3,8,4,-1,-1,-1,-1,-1};
  26. int b[5]={1,3,4,3,0};
  27. myArray c=uni(a,b);
  28. for(int i=0;i<10;i++)
  29. cout<<c.array[i]<<" ";
  30. cout<<"\n";
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1 3 3 8 4 1 3 4 3 0