方法 C · 通用兜底
成员访问,通过结构体变量用点号访问其成员。
怎么用
结构体变量.成员名
小例子
#include <stdio.h>
int main(void) {
struct Student { char name[20]; int score; };
struct Student s = {"小明", 90};
s.score = 95;
printf("%d", s.score);
return 0;
}
运行结果
输出 95
提醒:普通结构体变量用点号;指针要用 ->
官方文档:https://en.cppreference.com/w/c/language/operator_member_access
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C全部词条