代码运行问题
#include<stdio.h>#include <string.h>
#define POWER_RECORD_SEND_COUNT 10
typedef unsigned short WORD;
typedef struct powerRecord
{
WORD power;//DWORD power;//Johnson--120216
WORD time;
}PowerRecord;
PowerRecord rcArray[POWER_RECORD_SEND_COUNT]=
{
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
{0x0001,0x0002},
};
unsigned char data[40];
int main(void)
{
unsigned char i=0;
memcpy(data,&rcArray,40);
if(data[0]==0x00)
printf("this is test right");
else
printf("this is test error");
getchar();
return 0;
}
为什么打印出来的是this is test error, memcpy为什么会出错。复制过去data【0】应该是0x00吧