So my question is pretty simple:
I need to populate a char / unsigned char array with some information. Some middle values ββare taken from short / int types, and this happens:
the code:
int foo = 15;
unsigned char buffer[100]={0};
..
memcpy(&buffer[offset], &foo, sizeof(int));
...
Conclusion:
... 0F 00 00 00 ..
So, now I have written a function to change these fields, but I do not consider this an intelligent solution, as it affects the runtime, resources and development time.
Is there an easier way to do this?
:
, - endian, . int/short big-endian, , , / endian, , .
. ++