hi
Imagine that I have the following variables:
unsigned long a = 1; //32-bit value
unsigned short b = 1; //16-bit value
unsigned char c ='\x01' //8-bit value
unsigned char buffer[7];
Now I would like to map or combine those variables above in the buffer as follows: first four bytes should be occupied by value of int a, next 2 bytes by value b and the last byte by c.
==> buffer = 0x 00000001 0001 01
Is here anyone aware of an easy way to do that in C++? At the moment I am having help function that return the byte pattern for shorts and integers but I guess in C++ there must be a better way to do that?
Thanks