Struct vs. Union
if you defined:
struct s
{
int i;
char c;
}
when you define a variable of type s, a memory of size equals to the size of integer + the size of character will be reserved.
In contrasts, when you define:
union u
{
int i;
char c;
}
A variable of type u, results in the reservation of memory size of the max of integer and character, and this makes you are able to use the type u as either integer OR character.
summary:
struct = AND
unio = OR
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment