I have this sample code which I decorated with pack to make sure that its size if 5 byte (4 for int and 1 for char).
but it print out that the size of struct is 8 byte.
#pragma pack push
#pragma pack 1
struct mystruct
{
int x;
char y;
};
#pragma pack pop
//static_assert(sizeof(mystruct) == 5, "Size of mystruct should be 5 byte.");
int _tmain(int argc, _TCHAR* argv[])
{
int x=sizeof(mystruct);
printf("size of struct is %d\n",x);
return 0;
}
Why te pck is not working?
How can make sure that size of struct is always 5.