Syntax *Chapter 9*4 Pointer to Array of Structures

#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; // Be careful not to have address symbols 
  for (;sp<stu+ 3 ;sp++ ){
        printf("%d %s %0.1f\n",sp->num,sp->name,sp->score);
  }
}

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325214316&siteId=291194637