火火火-结构指针访问指针成员出错
typedef struct{
byte Head;
byte Length;
byte Cmd;
byte *Data;
byte *End1;
byte *End2;
byte *End3;
}SturctComData;
uint8_t TxBuf[20] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07};
void TestStructPoint(void)
{
SturctComData *tDataCom = (SturctComData*)TxBuf;
tDataCom->Data = &tDataCom->Cmd + 1; //这里完成指针的初始化
tDataCom->End1 = tDataCom->Data + tUartCom->Length;
tDataCom->End2 = tDataCom->End1 + 1;
tDataCom->End3 = tDataCom->End2 + 1;
tDataCom.Head = 0x66;
tDataCom.Length = 0x07;
tDataCom.Cmd = 0x01;
for(i=0; i<Len; i++)
{
*tUartCom ->Data ++ = *Data++; //????????前面已经将Data指针指向了TxBuf的TxBuf[03],为何这里会出错,请高手指点?
}
}
问题点如问号所处所描述,请高手指点,谢谢!