#include <stdio.h>
#define print_ptr(x) _Generic((*x), \
char: printf("%c\n", *(char *)x), \
int: printf("%d\n", *(int *)x), \
short: printf("%hi\n", *(short *)x), \
float: printf("%f\n", *(float *)x), \
double: printf("%lf\n", *(double *)x), \
default: printf("error"))
int main(int argc, char *argv[])
{
char c = 'a';
int n = 10;
print_ptr(&c);
print_ptr(&n);
void *ptr = &c;
print_ptr(ptr);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgcHJpbnRfcHRyKHgpIF9HZW5lcmljKCgqeCksIFwKCQkJCQkJCSAgY2hhcjogcHJpbnRmKCIlY1xuIiwgKihjaGFyICopeCksIFwKCQkJCQkJCSAgaW50OiBwcmludGYoIiVkXG4iLCAqKGludCAqKXgpLCBcCgkJCQkJCQkgIHNob3J0OiBwcmludGYoIiVoaVxuIiwgKihzaG9ydCAqKXgpLCBcCgkJCQkJCQkgIGZsb2F0OiBwcmludGYoIiVmXG4iLCAqKGZsb2F0ICopeCksIFwKCQkJCQkJCSAgZG91YmxlOiBwcmludGYoIiVsZlxuIiwgKihkb3VibGUgKil4KSwgXAoJZGVmYXVsdDogcHJpbnRmKCJlcnJvciIpKQppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKQp7CgljaGFyIGMgPSAnYSc7CglpbnQgbiA9IDEwOwoJcHJpbnRfcHRyKCZjKTsKCXByaW50X3B0cigmbik7Cgl2b2lkICpwdHIgPSAmYzsKCXByaW50X3B0cihwdHIpOwogICAgcmV0dXJuIDA7Cn0=