variadic.c 289 B

12345678910111213141516
  1. // variadic.c -- variadic macros
  2. #include <stdio.h>
  3. #include <math.h>
  4. #define PR(X, ...) printf("Message " #X ": " __VA_ARGS__)
  5. int main(void)
  6. {
  7. double x = 48;
  8. double y;
  9. y = sqrt(x);
  10. PR(1, "x = %g\n", x);
  11. PR(2, "x = %.2f, y = %.4f\n", x, y);
  12. return 0;
  13. }