考点
1 2 3 4 5 6 7 8 9 10 | // 2012_03_C_37 struct MP3 { char name[20]; char color; float price; } std,*ptr; ptr=&std; |
有三种引用方式: std.color, ptr->color, (*ptr).color
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // 2012_03_C_38 #include <stdio.h> struct stu { int num; char name[10]; int age; }; void fun(struct stu *p) { printf("%s\n",p->name); } main() { struct stu x[3]={{01,"Zhang",20},{02,"Wang",19},{03,"Zhao",18}}; fun(x+2); } |
2011_3_C_38:阅读程序
1 2 3 4 5 6 7 8 9 10 | #include <stdio.h> #include <stdio.h> struct S { int a,b; } data[2]= {10,100,20,200}; main() { struct S p=data[1]; printf("%d\n",++(p.a)); } |
答案: 21