memcpy with struct and pointer
Hi everyone.
I am trying the following.
Code:
//*********************
typedef struct{
unsigned char Dlength;
unsigned char *Value;
} AttributeA;
//In the main
unsigned char userData[] = {0x01,0x02,0x03,0x04,0x5};
AttributeA buffSrc;
AttributeA buffDst;
buffSrc.Dlength = 5;
buffDst.Dlength = 5;
buffSrc.Value = userData;
memcpy(buffDst.Value, buffSrc.Value, buffDst.Dlength);
//**********************
printf of buffSrc.Value gives me the output = 0x01,0x02,0x03,0x04,0x5;
But printf of buffDst.Value does not give the expected output (as buffSrc.Value).
I wonder what am I doing wrong?
I have even tried
memcpy(&buffDst.Value[0], &buffSrc.Value[0], buffDst.Dlength);
I shall appreciate.