/******************************************************************************/ /* */ /* D A T A T E S T */ /* */ /* Program: DATATEST */ /* */ /* Programmer: David G. Simpson */ /* NASA Goddard Space Flight Center */ /* Greenbelt, Maryland 20771 */ /* */ /* Date: December 3, 2004 */ /* */ /* Language: C */ /* */ /* Version: 1.00a */ /* */ /* Description: Print information about C data types, including sizes of */ /* each type and whether the default char type is signed or */ /* unsigned. */ /* */ /* Note: If your compiler has a "long long" type, you may un-comment */ /* the printf statement for "long long". */ /* */ /******************************************************************************/ /******************************************************************************/ /* #include */ /******************************************************************************/ #include /******************************************************************************/ /* main() */ /******************************************************************************/ int main(void) { char ch; printf("\nsizeof(char) = %2d byte = %3d bits\n", sizeof(char), 8*sizeof(char)); printf("sizeof(int) = %2d bytes = %3d bits\n", sizeof(int), 8*sizeof(int)); printf("sizeof(short) = %2d bytes = %3d bits\n", sizeof(short), 8*sizeof(short)); printf("sizeof(long) = %2d bytes = %3d bits\n", sizeof(long), 8*sizeof(long)); /* printf("sizeof(long long) = %2d bytes = %3d bits\n", sizeof(long long), 8*sizeof(long long)); */ printf("sizeof(float) = %2d bytes = %3d bits\n", sizeof(float), 8*sizeof(float)); printf("sizeof(double) = %2d bytes = %3d bits\n", sizeof(double), 8*sizeof(double)); printf("sizeof(long double) = %2d bytes = %3d bits\n\n", sizeof(long double), 8*sizeof(long double)); ch = 0xFF; if (ch < 0) printf("Default char is signed.\n\n"); else printf("Default char is unsigned.\n\n"); return 0; }