#include /* * Program to display sizes and constants for various types. * May give different results on different systems (e.g., 32-bit versus 64-bit). */ #include /* has constants for int types */ #include /* has constants for float types */ #include /* has uint* types */ int main(void) { printf("short has size %zd, min 0x%0hx, max 0x%0hx\n", sizeof(short), SHRT_MIN, SHRT_MAX); printf("int has size %zd, min 0x%0x, max 0x%0x\n", sizeof(int), INT_MIN, INT_MAX); printf("long has size %zd, min 0x%0lx, max 0x%0lx\n", sizeof(long), LONG_MIN, LONG_MAX); printf("long long has size %zd, min 0x%0llx, max 0x%0llx\n", sizeof(long long), LLONG_MIN, LLONG_MAX); printf("float has size %zd, %d mantissa bits, exp in [%d, %d]\n", sizeof(float), FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP); printf("double has size %zd, %d mantissa bits, exp in [%d, %d]\n", sizeof(double), DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP); printf("long double has size %zd, %d mantissa bits, exp in [%d, %d]\n", sizeof(long double), LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP); printf("char* has size %zd\n", sizeof(char *)); printf("int* has size %zd\n", sizeof(int *)); printf("float* has size %zd\n", sizeof(int *)); printf("size of int8_t %zd\n", sizeof(int8_t)); printf("size of int16_t %zd\n", sizeof(int16_t)); printf("size of int32_t %zd\n", sizeof(int32_t)); printf("size of intptr_t %zd\n", sizeof(intptr_t)); return 0; }