我正在将一个项目处理为一个结构数组......然后将该元素从结构数组复制到一个字符数组......但只有每 1/20 工作?
typedef struct{
double dTime;
char cMessage[11];
} typeCanMessage;
typeCanMessage *m_cmMessageCB = new typeCanMessage[1000]; //max size can be the CB
memcpy(m_cmMessageCB + *m_posWrite * sizeof(typeCanMessage), &m_cmMessageWrite, sizeof(typeCanMessage));
// WORKS
//memcpy(cStr, &m_cmMessageWrite.cMessage, 11);
// FAILS: every 1/20 works
memcpy(cStr, m_cmMessageCB->cMessage + *m_posWrite * sizeof(typeCanMessage), 11);