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