fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int* uniao(int *v1, int n1, int *v2, int n2) {
  5. int *v3 = malloc((n1 + n2) * sizeof(int));
  6. for (int i = 0; i < n1; i++) v3[i] = v1[i];
  7. for (int i = n1, j = 0; j < n2; i++, j++) v3[i] = v2[j];
  8. return v3;
  9. }
  10.  
  11. int main(void) {
  12. int v1[] = { 1, 2, 3 };
  13. int v2[] = { 4, 5, 6 };
  14. int *pAux = uniao(v1, 3, v2, 3);
  15. for (int i = 0; i < 6; i++) {
  16. printf("%d\n", pAux[i]);
  17. }
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/251687/101
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
1
2
3
4
5
6