This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

union/struct problem

Hello,

it works in devcpp (as c project) but not working in Keil. What is my fault.
output must be "12345" but it is not.

typedef union {
        u8      Reg8[5];
        struct
        {
                u8      Select;
                u32     Value32;
        }Regs;
}CreditLoadRegs_t;


const char  MyArray[]={"12345"};

void MyFonc(char *Buf)
{
    CreditLoadRegs_t *fPtr = (CreditLoadRegs_t *)Buf;
    printf("%s",fPtr->Reg8);
}

int main(void)
{
    MyFonc(MyArray);

    return 0;
}

Parents Reply Children