标题:代码运行问题
取消只看楼主
m564522634
Rank: 2
等 级:论坛游民
帖 子:34
专家分:16
注 册:2010-9-1
结帖率:60%
已结贴  问题点数:7 回复次数:2 
代码运行问题
#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吧
搜索更多相关主题的帖子: include power 
2013-11-17 19:35
m564522634
Rank: 2
等 级:论坛游民
帖 子:34
专家分:16
注 册:2010-9-1
得分:0 
打印出来是0
2013-11-17 21:09
m564522634
Rank: 2
等 级:论坛游民
帖 子:34
专家分:16
注 册:2010-9-1
得分:0 
楼上说的不错,是小端格式了谢谢了给分了
2013-11-18 21:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-423683-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.124901 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved