正在加载图片...
91结控体 结构体类型与变量的说明 struct date f int year,month, day; 3; num 8个字节 struct student name 30个字节 i char num[8 1个字节 char name 301; year2个字节 char sex: struct date birth d/ birthdaymonth2个字节 char addr 60li day2个字节 int score|6]」 addr 60个字节 score 12个字节 对象。 2021/2/202021/2/20 7 9.1 结构体 结构体类型与变量的说明 ⚫ 类型与变量是不同的概念。 ➢ 应先定义一个结构体类型,而后再定义结构体变量。 ➢ 系统对类型不分配空间,仅对变量分配空间。 ➢ 只能对变量赋值、存取或运算,而不能对一个类型 赋值、存取或运算。 ⚫ 成员也可以是结构变量。 ⚫ 对结构中的成员,可以单独使用,它的作用与 地位相当于普通变量。 ⚫ 成员名可与程序中的变量名相同时,也可与不 同结构体类型的成员名相同,二者代表不同的 对象。 struct date { int year,month,day;}; struct student { char num[8]; char name[30]; char sex; struct date birthday; /* 成员为结构体类型 */ char addr[60]; int score[6]; }; num 8个字节 name 30个字节 sex 1个字节 birthday year 2个字节 month 2个字节 day 2个字节 addr 60个字节 score 12个字节
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有