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