我定义了两个结构,一个结构包含了另一个,但却不能赋值请教一下怎么解决typedef struct
{
WORD *x;   //X坐标+14 
WORD *y;   //Y坐标+16 
WORD *z;   //方向+18 
BYTE Lx;   //0x1A //怪物的类型
}Role_Base_info,*pRole_Base_info;typedef struct
{
pRole_Base_info Base_info;
WORD *Money;
WORD *Weight;
}Role_info以下是赋值代码
pb=(int*)ID;
Role=new Role_info;
Role->Base_info->x =(WORD*)(int*)(*pb+0x14);
Role->Base_info->y =(WORD*)(int*)(*pb+0x16);
Role->Weight =(WORD*)(int*)(*pb+0x75);
最后一句赋值不会错,上面的两句会出错,程序退出
我要怎么赋值呢

解决方案 »

  1.   

    *Role->Base_info.x            =(WORD*)(int*)(*pb+0x14);
      

  2.   

    Role->Base_info->x            =(WORD*)(int*)(pb+0x14);
      

  3.   

    这样会报错啊,
    dllinject.exe 中的 0x00415e2f 处有未经处理的异常: 0xC0000005: 写入位置 0xcdcdcdcd 时发生访问冲突
      

  4.   

    pRole_Base_info Base_info;
    未初始化
      

  5.   

    经过1楼用法联想到的,我第一次用VC++不太熟,改进后将方法写下来*Role->Base_info.x =(WORD*)(int*)(*pb+0x14);
    typedef struct
    {
        Role_Base_info Base_info;  //这里做了一下修改不定义成指针
        WORD    *Money;
        WORD    *Weight;
    }Role_infoRole->Base_info.x =(WORD*)(int*)(*pb+0x14);经过上面的改进就正确了
      

  6.   

    Role=new Role_info;
    Role->Base_info = new Role_Base_info;