In our application header and trailor to be added to message and sent of fixed length. The header and trailor are to be sent as hex constant values. so that
it is interpreted on hex on another end...

ex Field1 - 00E7 - size 2 bytes.
Field2- 0002 - size 2 bytes.
On other end too the hex they look for 00E70002..... which should be equivalent to buffer data of ..

Tried formatting by assigning hex values to char array.but
it is not properly interpreted on other end. In addition null gets added to length and they receive one byte addition to expected
length and error out.
please provide how this can be done avoiding the addition of null at End of string and adding 1 byte to length..can this be done with memcpy...tried byt getting different values..