fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int* o1, int* o2) {
  4. *o1 ^= *o2;
  5. *o2 ^= *o1;
  6. *o1 ^= *o2;
  7. }
  8.  
  9. int main(void) {
  10. int t1 = 15;
  11. int t2 = 51;
  12. printf("Unswapped: %d, %d\n", t1, t2);
  13. swap(&t1, &t2);
  14. printf("Swapped: %d, %d\n", t1, t2);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Unswapped: 15, 51
Swapped: 51, 15