/*--------------------------------------------------------------------*/ /* sizes.c */ /* Author: Bob Dondero */ /* Determine the size of each fundamental data type. */ /*--------------------------------------------------------------------*/ #include int main(void) /* Write the size, in bytes, of each fundamental data type to stdout. Return 0. */ { printf("char: %d\n", (int)sizeof(char)); printf("unsigned char: %d\n", (int)sizeof(unsigned char)); printf("short: %d\n", (int)sizeof(short)); printf("unsigned short: %d\n", (int)sizeof(unsigned short)); printf("int: %d\n", (int)sizeof(int)); printf("unsigned int: %d\n", (int)sizeof(unsigned int)); printf("long: %d\n", (int)sizeof(long)); printf("unsigned long: %d\n", (int)sizeof(unsigned long)); printf("float: %d\n", (int)sizeof(float)); printf("double: %d\n", (int)sizeof(double)); printf("long double: %d\n", (int)sizeof(long double)); printf("pointer: %d\n", (int)sizeof(void*)); return 0; } /* Example execution: $ gcc217 sizes.c -o sizes $ sizes char: 1 unsigned char: 1 short: 2 unsigned short: 2 int: 4 unsigned int: 4 long: 4 unsigned long: 4 float: 4 double: 8 long double: 12 pointer: 4 */