c10.3结构体类型与数组 语言程亠 结构体数组的定义 设1.先定义结构体类型,后定义结构体数组 struct student students[1001 精2.结构体数组与结构体类型同时定义 课|3.不定义结构体类型名,直接定义结构体数组 荆程 struct student struct i long ID i long ID char name [10] char name [10] nt age int age; float score [3] float score [31 f students[100] I students [100] 技术系 103结构体与数组
结束 首页 上页 下页 末页 节 10.3 结构体类型与数组 一. 结构体数组的定义 1. 先定义结构体类型,后定义结构体数组 struct student students[100]; 2. 结构体数组与结构体类型同时定义 struct student { long ID; char name[10]; int age; float score[3]; }students[100]; 3. 不定义结构体类型名,直接定义结构体数组 struct { long ID; char name[10]; int age; float score[3]; }students[100]; 10.3 结构体与数组
C匚.结构体数组的初始化与结构体数组元素的引月 语言程序设计精品课 1.结构体数组的初始化 struct person 1 ong char name [10] char sex struct date birthdate: char department [30] float salary; 荆程 char address [30] f employee [3] {1001,”张山”,’M,1990,3,5,”计算中心”,545,”长 沙” 1002,”李红”,’F,1989,10,1,”信息学院”,643,” 汉”} 1003,”王武”,’M,1987,4,15,”人事处”,745,”广 州”}}; 技术系 103结构体与数组
结束 首页 上页 下页 末页 节 二.结构体数组的初始化与结构体数组元素的引用 1. 结构体数组的初始化 struct person {long ID; char name[10]; char sex; struct date birthdate; char department[30]; float salary; char address[30]; }employee[3]= {{1001,”张山”,’M’,1990,3,5,”计算中心”,545,”长 沙”}, {1002,”李红”,’F’,1989,10,1,”信息学院”,643,”武 汉”}, {1003,”王武”,’M’,1987,4,15,”人事处”,745,”广 州”}}; 10.3 结构体与数组
C employee[0 1001 ID(4字节) 语 长山 (10字节) sex(1字节) 程 birthdate(date类型,6字节) 共85个字节 "计算中心” department(30个字节) 设 545 aary(4字节) 长沙 个字节) 计 employee[] 1002 (4字节) 李 name(10字节) F (1字节) 精 1989 birthdate(date类型,6字节) 共85个字节 课 信息学院” department(30个字节) 荆程 salary(4字节) 武汉" address(30个字节) employee[] 1003 (4字节) (10字节) (1字节) 1987 birthdate(date类型,6字节) 共85个字节 "人事处 t(30个字节) alary(4字节) 广州 address(30个字节) 图11-2结构体数组的存储结构 103结构体与数组
结束 首页 上页 下页 末页 节 图11-2 结构体数组的存储结构 employee[1] 1002 ID(4字节) "李红" name(10字节) 10 sex(1字节) 1 birthdate(date类型,6字节) "信息学院" 643 salary(4字节) address(30个字节) 'F' 1989 "武汉" department(30个字节) 共85个字节 employee[2] 1003 ID(4字节) "王武" name(10字节) 4 sex(1字节) 15 birthdate(date类型,6字节) "人事处" 745 salary(4字节) address(30个字节) 'M' 1987 "广州" department(30个字节) 共85个字节 employee[0] 1001 ID(4字节) "张山" name(10字节) 3 sex(1字节) 5 birthdate(date类型,6字节) "计算中心" 545 salary(4字节) address(30个字节) 'M' 1990 "长沙" department(30个字节) 共85个字节 10.3 结构体与数组