Say i have a struct like
typedef struct {
unsigned char flag, type;
unsigned short id;
uint32 size;
} THdr;
and a buffer of data coming from a UDP comunication, i have a buffer of bytes and its size (data
and data_size
). data size is bigger than sizeof(THdr)
.
The struct is at the beginning of the buffer, and i want to copy it to a struct defined in the code, THdr Struct_copy
.
I know that i can use memcpy(&Struct_copy,data[0],sizeof(Struct_copy));
but i would like to use a "C++ style" way, like using std::copy
.
any clue?