PREV INDEX NEXT

Author: Unknown
Subject: Bit fields
Date: Wednesday, 11 Nov 2020, 23:07:41

I am not sure if I understand bit fields correctly. Say if I have the following struct:

typedef struct
{
    unsigned int code : 24;
    unsigned int prefix : 24;
    char k : 8;
} tableEntry;

Then the size of it would be 7 bytes? 

And 

typedef struct
{
    unsigned int code : 24;
    unsigned int prefix : 24;
    char k : 8;
    unsigned int somebool :1;
} tableEntry;

will be 8 bytes?

Thanks in advance!
PREV INDEX NEXT