Chinaunix首页 | 论坛 | 博客

分类: 信息化

2014-12-22 11:58:44


点击(此处)折叠或打开

  1. /*
  2.  -------------------------------------------------------------
  3.    **** date : 2014.12.22 ****
  4.    **** name : 结构体 ********
  5.    **** author : lishubo *******
  6.    -----------------------------------------------------------
  7. */
  8. #include<stdio.h>
  9. #include<string.h>
  10. #include<stdlib.h>


  11. struct information //结构体
  12. {
  13.     char name[30]; //定义4个char类型的变量
  14.     char number[30];
  15.     char classroom [30];
  16.     char sex[30];
  17. };
  18. void inselt_infor(char *name, char *number, char *classroom, char *sex, struct information *infor)
  19. {
  20.     strcpy((*infor).name, name);
  21.     strcpy((*infor).number, number);
  22.     strcpy((*infor).classroom, classroom);
  23.     strcpy((*infor).sex, sex);
  24. }
  25. void printf_infor(struct information infor)
  26. {
  27.     printf("%s\n", infor.name);
  28.     printf("%s\n", infor.number);
  29.     printf("%s\n", infor.classroom);
  30.     printf("%s\n", infor.sex);
  31. }
  32. int main()
  33. {
  34.     struct information infor1,infor2;
  35.     printf("******************************************\n");
  36.     printf(" 学生管理系统 \n");
  37.     printf("******************************************\n");
  38.     inselt_infor("name : jack","学号: 1424001","班级 :14wlw","性别 :male",&infor1);
  39.     inselt_infor("name : rose","学号: 1424002","班级 :14wlw","性别 :female",&infor2);
  40.     printf_infor(infor1);
  41.     printf_infor(infor2);
  42.     return 0;
  43. }



如图:

阅读(1205) | 评论(0) | 转发(0) |
0

上一篇:c语言

下一篇:打印出字母表

给主人留下些什么吧!~~