Hi,

i'm receiving some data from an UDP socket, that i would like to copy to a struct/class.

I have defined the following class:

class header
{
public:
unsigned char code;
unsigned char id;
unsigned char length[2];
unsigned char auth[16];
};

I've tried two ways:

First to use memcpy:
header *hdr;
memset(&hdr, 0, sizeof(header));

This works but is not C++.

Second using the following:
header *hdr;
hdr = (header *)data;


Is there a better way to do this?
Or is one of the above the right way?

Thanks in advance

/Torben