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