结构体打印学生信息

 1 #include "stdio.h"
 2 void main()
 3 {
 4         int i;
 5      struct student {
 6          int age;
 7          char *name;
 8          char *sex;
 9          char *hobby;
10      };
11      struct student ta[] = {
12     18,"学生1","","篮球",
13     19,"学生2","","看书",
14     18,"学生3","","学习单片机",
15     17,"学生4","","航模"
16      };
17      for(i=0;i<4;i++)
18      {
19         printf("%s  ",ta[i].name);
20          printf("%d  ",ta[i].age);
21          printf("%s  ",ta[i].sex);
22          printf("%s\n",ta[i].hobby);
23      }
24 }

 

posted on 2017-05-09 15:38  梁锦杰  阅读(508)  评论(0编辑  收藏  举报

导航

欢迎进入我的博客!