1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include<stdio.h> #include <string.h> struct Student { int sid; char name[100]; int age; }; void g(struct Student st); void g2(struct Student *pst); void f(struct Student *pst); int main(void) { Student st; f(&st); g(st); g2(&st); return 0; } void g(struct Student st) { printf("%d %s %d\n",st.sid, st.name,st.age); } void g2(struct Student *pst) { printf("%d %s %d\n", pst->sid, pst->name, pst->age); } void f(struct Student *pst) { (*pst).sid = 99; strcpy(pst->name, "zs"); pst->age = 22; }
|