+ 1
Can anybody explain the output of code?
2 Respostas
+ 3
Union stores only one element at a time, so all access the same memory spot. Size of the largest type, here int.
The last change was to 300.
Since a and b are char it shows 44 instead of 300, because chars repeat every 256 places so to say
(it,s actually because of bit representation and char being only 1 byte = 8 bit large, i.e. 2^8=256 possible values)
If you replace %d by %c, you will se the corresponding character.
+ 4
union stores its members in same memory location so when you change one of its members others change too