Skip to content

Instantly share code, notes, and snippets.

@Silva97
Created May 26, 2019 05:59
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 Silva97/c5896bb15192a836ed451af60bc8344d to your computer and use it in GitHub Desktop.
Save Silva97/c5896bb15192a836ed451af60bc8344d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define tostr(...) #__VA_ARGS__
#define type(x) _Generic(x, \
int: "int", \
unsigned int: "unsigned int", \
short int: "short int", \
int *: "int *", \
char: "char", \
char *: "char *", \
unsigned char: "unsigned char" \
)
int main(void)
{
short int teste_i;
printf("Nome: %s\n"
"Tipo: %s\n",
tostr(teste_i),
type(teste_i));
printf("Tudo: %s %s\n",
type(teste_i),
tostr(teste_i));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment