Question: Consider a C struct that includes the following members: struct foo { char a; int b; bool c; double d; short e; float f; char

Consider a C struct that includes the following members:
struct foo {
char a;
int b;
bool c;
double d;
short e;
float f;
char cptr;
double g;
float fptr;
};
a). Note that for C language, the compiler keeps the elements of the struct in the same order as given in the struct definition. For a 32-bit machine (each word contains 4 bytes or 32 bits), what is the size of the foo struct? Remember that data must be aligned on proper byte boundaries. That means, an 8 byte element must start at a byte address that is a multiple of 8; a 4 byte value must start at an address that is a multiple of 4.
b). What is the minimum size required for this struct, assuming you may arrange the order of the struct members as you wish?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!