访问结构体成员

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> // 访问结构体成员 struct person { char name[20]; int age; char email[50]; }; // 使用成员操作符 (.) 来访问各个成员,内部存储的数据 // pzs 是指针型,因此 可以通过-> 来访问其指向结构的数据成员 int main() { struct person zhangshan = {"zhangsan", 24, "zs@163.com"}; struct person *pzs = &zhangshan; printf("name: %s\n", zhangshan.name); printf("age: %d\n", zhangshan.age); printf("email: %s\n\n", zhangshan.email); printf("name: %s\n", pzs->name); printf("age: %d\n", pzs->age); printf("email: %s\n", pzs->email); }
Editor Settings
Theme
Key bindings
Full width
Lines