Skip to content

Instantly share code, notes, and snippets.

@jrfondren
Created October 10, 2019 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrfondren/86980d0b63e993c5bd4821a9f5f6914e to your computer and use it in GitHub Desktop.
Save jrfondren/86980d0b63e993c5bd4821a9f5f6914e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define print(X) _Generic((X), \
double: printf("%f\n", X),\
int: printf("%d\n", X),\
char: printf("%c\n", X))
int main (void) {
int x = 42;
double z = 11.0;
print(x);
print(z);
print((char)'a');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment