How can I know the actual structure size?
using sizeof returns the number of bytes after alignment.
For example :
struct s {
char c;
int i
}
sizeof(s) = 8;
I am interested to get the size of bytes without alignment ,i.e 5
sizeof returns the actual structure size.
The size without padding is a bit meaningless, because the compiler will insert the padding it feels appropriate. Some compilers support pragmas that turn off structure padding, in which case you should use that, but you’ll probably get all sorts of fun things happening.