/* 定义个结构体 */
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));
本文深入探讨了C语言中结构体的定义方法及其初始化过程,包括如何使用memset函数将结构体成员设置为零。
679

被折叠的 条评论
为什么被折叠?



