If i define a char variable
char a;
and a structure with a single char member
struct OneChar {
char a;
};
<
Various compilers will optimize to add padding between or at the end of the struct. So, it's not safe on all compilers or platforms to assume the allocated size is what it seems. Check your compiler options for setting struct padding.
For instance, Visual Studio uses the #pragma pack directive to override default optimizations.