+ 1
Basically a structure is a record in memory while a union defines a memory location as being used for more than one purpose. Structure format: Start end name type 1. 4. Num int 5. 5. Chr Char Num = 1 Chr = '2' Printf("%d %c",Num, Chr); Result is 1 2 Union format Start end name type 1. 4. Num int 1. 1. Chr Char Num = 1 Chr = 2 Printf above run with this will result in printing an unknown value for num and 2 for chr. Since putting a value in either variable overwrites at least part of the other variable it is impractical to try to anticipate the effect one variable will have on the other. Hope this explanation is helpful to you.
2nd Feb 2019, 6:15 AM
Roger Greenlaw