初学结构体(一)
#include<stdio.h>struct Student{int age;float score;char sex;};main(){struct Student st={25,88,'M'};printf("%d\n",st.age); struct Student *pst=&st;pst->age=100;printf("%d\n",st.age);printf("%d",pst->age); }
構造結構體并且輸出,方式不同。指針or st.XXX
*pst=&st;
pst->age
看了很多->這個符號,一直不懂什么意思,現在終于算有點了解了。
定義指針變量后,可以直接用地址指向它的成員變量。
總結
- 上一篇: 谷歌云发布 AI 搜索功能 Vertex
- 下一篇: 结构体跨函数应用(二)