I need to deal with some data in the following form:
typedef struct{
unsigned n1 : 12;
unsigned n2 : 12;
unsigned n3 : 12;
unsigned n4 : 1;
unsigned n5 : 35;
} data;
I made sure that in total they count up to 9 bytes.
But they don't.. Writing 9 bytes of that struct to a file and reading it back doesn't restore all the data, and sizeof(data)
returns 16.
What's the problem here ?