union taylormade { struct mizuno *t; struct mizuno *w; int tw; };
struct mizuno {
char hmmb[2];
int irons[4];
union taylormade t;
};
what is the size in bytes of the struct above?
The size of the structure is 32 bytes.
Explanation:
The statement by statement explanation of the given source code is given below:
union taylormade
{
struct mizuno *t; // 8 bytes
struct mizuno *w; // 8 bytes
int tw; // 4 bytes
};
struct mizuno
{
char hmmb[2]; // 2 bytes
int irons[4]; // 16 bytes
union taylormade t;// 8 bytes
};
The C language has a lot of built-in data type and we can create our own data type as well by using:
The structure can be used to combine different data types.
The union is a special case of a structure in which different data types are stored at the same memory location. So, for given example, the size of the union is considered as 8 bytes only.
Get Answers For Free
Most questions answered within 1 hours.