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