This is undefined behavior, you can't store a field in a union and retrieve it as another type. Thus, you can't really "expect" any output from this piece of code, because anything is acceptable as far as the standard is concerned.
See this question: A question about union in C
Apart from that, since 512 is 2^9, assuming integers are 32 bits and chars are 8 bits, this just means that your architecture is little endian, because 512 is 0x200. When you access e1.name[0]
and e2.name[1]
, you are accessing the first 2 bytes of 512 that were stored in memory, which apparently happens to be 0x00 (the least significant byte), and 0x2 (next byte after the least significant).