If I take the following struct:

struct x
{
unsigned char t;
unsigned char w;
unsigned char a;
};

If this struct is used to create a byte for output to a file and from the above struct t is 4 bits and occupies the MSBs, w is 2 bits and a is 2 bits following.
What is the best way using bitwise and shift operations for me to achieve the right structure in the resulting byte.