第一个
指向结构体变量的指针
#include<stdio.h>
int main()
{
struct student
{
int num;
char name[20];
float score;
} st={1102,"张三",89},*p=&st;
printf("%6d ",p->num);
printf("%s ",p->name);
printf("%.0f\n",p->score);
return 0;
}
#include<stdio.h>
int main()
{
struct student
{
int num;
char name[20];
float score;
} st[3]={{1102,"张三",89},{1102,"张一",89},{1102,"张二",90}},*p=st;/*若前面的“,”改为“;”则struct student *p=st */
int i;
for(i=0;i<3;i++,p++)
{
printf("%6d ",p->num);
printf("%s ",p->name);
printf("%.0f\n",p->score);
}
return 0;
}