Hello everyone,


I heard when define a struct, it is important to make the size of the struct memory aligned.

For example,

Code:
struct foo
{
    char p;
    char[3] align;
};
Code:
struct goo
{
    char p;
};
struct foo is better than struct goo, even if we only use member p.

Allocate 3 bytes to align with memory. But I do not know why make memory aligned is better. Any reasons? (for example, prevent memory from running out?)


thanks in advance,
George