Correct the alignment of structure below that is bad.
typedef struct{
char *string; // 4 byte (type of address int)
char temp; // 1 byte
short pick; // 2 byte
char temp2; // 1 byte
}hello;
- string = 4
- temp + pick + temp2(offset 7) = 1+2+1
answer given, good alignment is
char *string; // 4 byte (type of address int)
short pick; // 2 byte
char temp; // 1 byte
char temp2; // 1 byte
- string = 4
- pick + temp + temp2(offset 7) = 2+1+1
unable to understand the reason that says temp2 should be at offset 7 rather than 8. how? please help