Suppose I have a 16bit data type, short in C, and I want it to represent two characters, 'H' and 'U', in a way, this short would act like a char vector of length 2, char[2].
This is the code:
short hum; memset(&hum, 0, sizeof(short)); memcpy(&hum+0, "H", sizeof(char)); memcpy(&hum+1, "U", sizeof(char));
I don't know if memory addresses can be handled in this byte by byte approach, ignoring the real data type size, this would be better than using bit shift and OR operator, I believe.
Thanks for the help in advance.







