导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→结构指针的问题请帮忙[QQ800127]

 *第14371篇: 结构指针的问题请帮忙

  
楼 主:QQ800127 2003年7月12日11:00
 结构指针的问题请帮忙
#define uchar unsigned char
#define uint unsigned int
typedef idata struct  yyy
{
 uchar a;
 uchar b;
 uint ab;
/*
 union sa
 {
  uchar high;
  uchar low;
  uint word;
 } ss;
*/
} dd;
 dd *test;
 dd *best;
void main(void)
{
 uint address;
 address = test;
 test->  a = 0x55;    //1
 test->  b = 0xaa;    //2
 test->  ab= 0x1111;  //3
 best->  b = test->  a; //4
 while(1);
}
哪位大侠给看看,其中3、4正确,1、2得不到相要的数,用的是keil进行软仿真。谢谢
  
2楼:liugn 2003年7月13日13:38
 因为你仅仅声明了指针,没有声明结构对象实体
应该用这样的代码

dd test;
uint address;
address = &test;
address ->  a = 0x55;

 test->  a = 0x55;    //1
 test->  b = 0xaa;    //2


>>>>>>对该主题发表你的看法

本主题贴数2,分页: [第1页]


[上一篇主题]:Atmel AT89ISP Cable

[下一篇主题]:谁能帮我解释一下KEIL51错误提示的符号都是啥意思,如A9