结构体和共用体讲述.pptVIP

  • 16
  • 0
  • 约1.34万字
  • 约 47页
  • 2016-12-27 发布于湖北
  • 举报
* 结构体与共用体 结构体概述 结构体变量 结构体数组 共用体 枚举类型 用typedef定义类型 * 结构体数组 结构体数组的定义与初始化 1. 结构体数组的定义 结构体数组:数组的成员是结构体类型数据元素。 在定义结构体数组时,其定义方法与定义 结构体变量方法类似,也有三种形式。 第一种定义方式: * struct date_type { int year; int mouth; int day; }; struct stud_type { char name[10]; long num; char sex; struct date_type birthday; float score; char address[10]; }; struct stud_type student[3]; 由此就定义了一个结构体数组,数组名是student1,它有3个元素,每个元素都是struct stud_type类型 每个数组元素各占41个字节 (10+4+1+(4+4+4)+4+10=41)共占41*3个字节。 * 2. 结构体数组的初始化 结构体数组

文档评论(0)

1亿VIP精品文档

相关文档