0

Hi I have a problem with converting a struct..

I got 2 different structs but they have the "same" data.

Struct1:

struct sStruct1
{
    BYTE  Base1;
    WORD  Base2;
    float Base3;
}

Struc2:

struct sStruct2
{
    BYTE*  Base1;
    WORD*  Base2;
    float* Base3;
}

Now I the problem: I have data inside the struct1 but I need to fill struct2 with the same data.
I have no idea how I could do this..

I tryed this but no luck

DWORD ConvertBYTE(void* pvValue, void* pvBuffer)
{
    BYTE* pbyBuffer = (BYTE*)pvBuffer;
    *pbyBuffer = *((BYTE*)pvValue);

    return sizeof(BYTE);
}
3
Contributors
2
Replies
25
Views
3 Years
Discussion Span
Last Post by uonsin
0

Just copy the data.

sStruct1 first;
sStruct2 second;

...

first.Base1 = *(second.Base1);
first.Base2 = *(second.Base2);
first.Base3 = *(second.Base3);

...

*(second.Base1) = first.Base1;    
*(second.Base2) = first.Base2;
*(second.Base3) = first.Base3;

Edited by Moschops

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.