/* This program illustrates the union data type. The three fields num.integer_num, num.unsigned_num, and num.float_num are initially set to 0. Only num.integer_num is modified to -1. However, the values of num.unsigned_num and num.float_num are all changed because the three fileds share the same memory location. */ #include int main(void) { union number_union { int integer_num; unsigned unsigned_num; float float_num; } num; num.integer_num = 0; num.unsigned_num = 0; num.float_num = 0; num.integer_num = -1; printf("Integer: %d\n", num.integer_num); printf("unsigned: %u\n", num.unsigned_num); printf("float: %f\n", num.float_num); printf("address of num.integer_num: 0X%X\n", &num.integer_num); printf("address of num.unsigned_num: 0X%X\n", &num.unsigned_num); printf("address of num.float_num: 0X%X\n", &num.float_num); system("pause"); return 0; }