张赐荣——一位视障程序员。
赐荣小站: www.prc.cx

張賜榮

张赐荣的技术博客

博客园 首页 新随笔 联系 订阅 管理

C语言使用指针指向结构体

#include <stdio.h>
struct Student
{
char name;
int age;
};
int main(void)
{
struct Student a,*p;
p = &a;
p->name = 'a';
p->age = 12;
printf("%c\n%d\n",a.name,a.age);
printf("%c\n%d\n",p->name,p->age);
return 0;
}

/*
注:当用地址逆运算符星号(*)访问结构体成员时,用的不是"."成员访问符,而是"->"。
*/

posted on 2022-03-21 15:49  张赐荣  阅读(44)  评论(0编辑  收藏  举报

感谢访问张赐荣的技术分享博客!
博客地址:https://cnblogs.com/netlog/
知乎主页:https://www.zhihu.com/people/tzujung-chang
个人网站:https://prc.cx/