C语言访问结构成员的3种等价形式

来源:学生作业学帮网 编辑:学帮网 时间:2024/06/06 02:43:04

C语言访问结构成员的3种等价形式

struct student
{
char *name ;
int age ;
};
student a = {"Tom", 20} ;
a.name = "zdd" ;// 第一种
student *s = new student() ;
s->name = "Tom" ; // 第二种
(*s).age = 18 ;// 第三种