C语言结构体指针总结

main.c:

int32_t main(void)

{

        ObjDetection_Perframe* rawcloudpoints;
        rawcloudpoints = (ObjDetection_Perframe*)malloc(sizeof(ObjDetection_Perframe));

        printf(" %x\n %x\n %x\n %x\n %x\n %x\n %d\n %d\n %d\n %d\n %d\n", rawcloudpoints, &(rawcloudpoints->detList), &(rawcloudpoints->frameNum), &(rawcloudpoints->vel), &(rawcloudpoints->yaw), &(rawcloudpoints->num), sizeof(ObjDetection_Perframe), sizeof(float), sizeof(double), sizeof(rawcloudpoints->detList), sizeof(rawcloudpoints));

        return 0;

}

main.h:

typedef struct Cloud_Points_Perframe_t
{
    float range;           //表示该detection的距离
    float doppler;        //表示该detection的doppler速度
    float vel;               //表示该detection的解模糊后的径向速度
    float aziAngle;      //表示该detection的方位角
    float eleAngle;     //表示该detection的俯仰角
    float sn;               //表示该detection的信噪比
    float x;                 //表示该detection的横向距离
    float y;                 //表示该detection的纵向距离
    float z;                 //表示该detection的高度
}Cloud_Points_Perframe;

typedef struct ObjDetection_Perframe_t
{
    Cloud_Points_Perframe* detList;         //表示该帧点云信息,是个数组,每个元素代表一个detection的信息
    uint32_t frameNum;                             //表示该帧的帧号
    float vel;                                               //表示该帧的自车速度
    float yaw;                                             //表示该帧的偏航角
    uint32_t num;                                      //表示该帧点云数量
}ObjDetection_Perframe;

输出:

总结:

数据类型:

 

 其他:

1.指针可以理解为一串含义为地址的二进制数(相较于变量的二进制表示变量值而言),指针取地址,表示存放该地址的指针在内存中的索引(地址);

2.结构体指针默认分配为float(不同编译器所占字节不同,x86为4字节,x64为8字节),其值为所对应的结构体内存的首地址(也就是该内嵌结构体的第一个成员的首地址),可用->直接访问得到该地址,若对其取地址,可得到该指针所存放的地址(也就是当前结构体存放该内嵌结构体指针的索引,即该指针的地址);

3.注意结构体字节对齐。


    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值