## memset 清除结构体的方法

来源:互联网 发布:最新网页制作软件 编辑:程序博客网 时间:2024/06/09 17:42
/* 定义个结构体 */struct DEMO_STR{    uint8_t name[10];    uint8_t sex[10];    ...};struct DEMO_STRUCT{    uint32_t port;    uint8_t data[100];    struct DEMO_STR stdudent;};/* 定义一个结构体变量 */struct DEMO_STRUCT mystruct;

用memset将这个结构体清0,使用

/* 清除这个结构体变量 */memset((void *)&mystruct, 0x0, sizeof(struct DEMO_STRUCT));
0 0
原创粉丝点击