Skip to content

Instantly share code, notes, and snippets.

@fritz0705
Created April 5, 2013 02:48
Show Gist options
  • Select an option

  • Save fritz0705/5316214 to your computer and use it in GitHub Desktop.

Select an option

Save fritz0705/5316214 to your computer and use it in GitHub Desktop.
/* gcc -o intlen intlen.c */
#include <stdio.h>
#define TYPE_INFO(type) #type, (sizeof(type) * 8), sizeof(type)
#define TYPE_FORMAT "%s\t%u\t%u\n"
int main(void)
{
puts("type\tbits\tbytes");
printf(TYPE_FORMAT, TYPE_INFO(char));
printf(TYPE_FORMAT, TYPE_INFO(short));
printf(TYPE_FORMAT, TYPE_INFO(int));
printf(TYPE_FORMAT, TYPE_INFO(long));
printf(TYPE_FORMAT, TYPE_INFO(long long));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment