that depends on what align settings you have in your compiler. For align crucial struct
's (for example for file-format decoding/encoding purposes) try this (in C++ language if you have different see the docs how to achieve similar functionality):
#pragma pack(1)
struct node
{
int data;
struct node *next;
};
#pragma pack()
In your case it looks like you have set align to 8 or 16 bytes. This property is used to align data to speed up memory access by better addressing math and less cache misses ...
#pragma pack(x)
temporarily sets align property to x
bytes
#pragma pack()
restore previous align setting.
You can look at these as a push and pop.
The align tells compiler on what size should align any struct/class/union
so they always start/end at multiple of align property address. This is important for pointer logic. For example if you have align to 8 or 16 and your structure is raw size 12 Bytes the compiler fills the rest with empty space to match multiple of align size (in your case add 4 bytes). This will lead to less CACHE misses (if align is big enough for your current CPU). Some compilers can also take advantage of this (in case of that size is power of 2) and change pointer math to bit shifts.
Try to search in your IDE for things like: Project->Options->Compiler->Align
But as few of you pointed out in some architectures un-aligned memory access is prohibited (like SPARC) and usually ends up with crash/exception.