glue.c 457 B

123456789101112131415
  1. // glue.c -- use the ## operator
  2. #include <stdio.h>
  3. #define XNAME(n) x ## n
  4. #define PRINT_XN(n) printf("x" #n " = %d\n", x ## n);
  5. int main(void)
  6. {
  7. int XNAME(1) = 14; // becomes int x1 = 14;
  8. int XNAME(2) = 20; // becomes int x2 = 20;
  9. int x3 = 30;
  10. PRINT_XN(1); // becomes printf("x1 = %d\n", x1);
  11. PRINT_XN(2); // becomes printf("x2 = %d\n", x2);
  12. PRINT_XN(3); // becomes printf("x3 = %d\n", x3);
  13. return 0;
  14. }