I am using ms C ++. I use struct as
struct header {
unsigned port : 16;
unsigned destport : 16;
unsigned not_used : 7;
unsigned packet_length : 9;
};
struct header HR;
this is the value of the header to be added to a separate char array.
I did memcpy(&REQUEST[0], &HR, sizeof(HR));
but the packet length value is not displayed properly.
as if I assigned HR.packet_length = 31; I get -128 (in the fifth byte) and 15 (in the sixth byte).
if you can help me with this, or if this is a more elegant way to do it.
thank
source
share