you can use bit fields
struct survey_data
{
unsigned short sex : 1;
unsigned short marital_status : 2;
unsigned short age : 2;
unsigned short education : 2;
unsigned short city : 2;
unsigned short region : 4;
unsigned short answer : 3;
};
if you need to convert it between short, you can define a union like this
union survey
{
struct survey_data detail;
unsigned short s;
};
to use these types
struct survey_data sd;
sd.sex = 0;
sd.marital_status = 2;
...
unsigned short s = 0xCAFE;
union servey x;
x.s = s;
printf("Sex: %u, Age: %u", x.detail.sex, x.detail.age);
keep in mind the layout of bit fields is implementation defined; different compiler may interpret them in different order, e.g. in MSVC, it is lsb to msb; pelase refer to the compiler manual and c/c++ standard for details.