Understanding the memory content of a union
问题 Suppose I define a union like this: #include <stdio.h> int main() { union u { int i; float f; }; union u tst; tst.f = 23.45; printf("%d\n", tst.i); return 0; } Can somebody tell me what the memory where tst is stored will look like? I am trying to understand the output 1102813594 that this program produces. 回答1: It depends on the implementation (compiler, OS, etc.) but you can use the debugger to actually see the memory contents if you want. For example, in my MSVC 2008: 0x00415748 9a 99 bb