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