I am a bit lost on calculating the size of structures
So we have the structure:
struct AcronymNode{
struct AcronymNode* next;
char acronym[5];
double num_phrases;
struct The_Phrase* phrase_list;
} Dictionary;
I see it as
next : 4bytes
acronym: 5bytes + 3
num_phrases: 8bytes
phraselist: 4bytes
=24 bytes
When I look at the notes it says: 32 bytes = 4 + 5 + 3 (alignment to word) + 4 (to align for the double) + 8 + 4 + 4 (to align next structure to a multiple of 8 for the double)
Why are we adding an extra 8 for alignment since it doesn't overflow, 4 before the double and 4 after the 2nd structure
In the more efficient structure it has double first, following the structures for 24 bytes
Also I wanted to check if this is right
structT{
int a;
char b[5];
float c;
char d[2];
};
Is the size 4 + 5+3 + 4 + 4 = 20?