Jul 5, 2008 #1 I impakt Member level 4 Joined Dec 19, 2005 Messages 68 Helped 2 Reputation 4 Reaction score 0 Trophy points 1,286 Activity points 1,799 Hello all, I have a question about unions. Suppose we have the following piece of code: Code: typedef struct { ... }type_struct1; typedef struct { ... }type_struct2; typedef union{ type_struct1* var1; type_struct2* var2; }type_union; Hoe much memory is allocated for the union in this case?
Hello all, I have a question about unions. Suppose we have the following piece of code: Code: typedef struct { ... }type_struct1; typedef struct { ... }type_struct2; typedef union{ type_struct1* var1; type_struct2* var2; }type_union; Hoe much memory is allocated for the union in this case?
Jul 6, 2008 #2 B btbass Advanced Member level 5 Joined Jul 20, 2001 Messages 1,896 Helped 438 Reputation 880 Reaction score 288 Trophy points 1,363 Location Oberon Activity points 12,887 In this case it is the size of one pointer which can point to two different types.
Jul 7, 2008 #3 M Mansour_M Full Member level 1 Joined Jul 30, 2006 Messages 99 Helped 11 Reputation 22 Reaction score 3 Trophy points 1,298 Location Newcastle, UK Activity points 1,944 Hi Dear Friend! Unions always occupies the space needed for the largest variable the have.