语法*第九章*4 指向结构体数组的指针

#include<stdio.h>
struct student{
   int num;
   char name[20];
   float score;
};
 int main(void){
  struct student stu[3]={112301,"bowen1",20,112111,"bowen2",10,110911,"bowen3",30};
  struct student *sp;
  sp=stu;//注意不要有地址符号
  for(;sp<stu+3;sp++){
        printf("%d %s %0.1f\n",sp->num,sp->name,sp->score);
  }
}

  

猜你喜欢

转载自www.cnblogs.com/sunnybowen/p/8977064.html