Can anyone please tell me how come the size of the structure shown below is 24 and not 20.
typedef struct
{
double d; // this would be 8 bytes
char c; // This should be 4 bytes considering 3 bytes padding
int a; // This would be 4 bytes
float b; // This would be 4 bytes
} abc_t;
main()
{
abc_t temp;
printf("The size of struct is %d\n",sizeof(temp));
}
My asumption is that the size of structure would be 20 when we consider padding but when i run this code the size is printing as 24.