fork(1) download
  1. #include <stdio.h>
  2. #define print_ptr(x) _Generic((*x), \
  3. char: printf("%c\n", *(char *)x), \
  4. int: printf("%d\n", *(int *)x), \
  5. short: printf("%hi\n", *(short *)x), \
  6. float: printf("%f\n", *(float *)x), \
  7. double: printf("%lf\n", *(double *)x), \
  8. default: printf("error"))
  9. int main(int argc, char *argv[])
  10. {
  11. char c = 'a';
  12. int n = 10;
  13. print_ptr(&c);
  14. print_ptr(&n);
  15. void *ptr = &c;
  16. print_ptr(ptr);
  17. return 0;
  18. }
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
a
10
error