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