fork(2) download
  1. #include <stdio.h>
  2.  
  3. void swap(int *x, int *y) {
  4. int z=*x;
  5. *x=*y;
  6. *y=z;
  7. }
  8.  
  9. int main() {
  10. int data1[5] = {1,2,3,4,5};
  11. int data2[5] = {6,7,8,9,10};
  12.  
  13. for (int i=0;i<5;i++) {
  14. swap(&data1[i],&data2[i]);
  15. }
  16.  
  17. for (int i=0;i<5;i++) {
  18. printf("%d ", data1[i]);
  19. }
  20. printf("\n");
  21.  
  22. for (int i = 0; i < 5; i++) {
  23. printf("%d ", data2[i]);
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
6 7 8 9 10 
1 2 3 4 5