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