/* This program illustrates the size of union data type. The union type will allocate enough memory space of the field with the largest memory space. In this case it is num.double_num of 8 bytes. */ #include int main(void) { union number_union { char character_num; int integer_num; float float_num; double double_num; } num; printf("size of num: %d\n", sizeof(num)); printf("size of num.character_num: %d\n", sizeof(num.character_num)); printf("size of num.integer_num: %d\n", sizeof(num.integer_num)); printf("size of num.float_num: %d\n", sizeof(num.float_num)); printf("size of num.double_num: %d\n", sizeof(num.double_num)); system("pause"); return 0; }