正在加载图片...
year 或 year 注意 算符具有相同的优先级与结合性。在这种情况下,运算符 “,”不能用“一>”来代替。 struct date int da char *month: int year } birthday={14,“Sep”,1951} struct employee char name [20]: double salary; long int tel char sex; struct date *q I person1=("HY. Jiang", 960. 86, 66341071, *p=&personl #include <stdio. h> main() i p->g=&birthday p->sex printf("Name: %s\nsex: %c\nDateOfBirth: %2d. %s. %4d\n Tele. No: %1d \n", p->name, p->sex, p->q->day p->q->month, p->g->year, p->tel) 公用体 5.5公用体p->q->year 或 (p->q)->year 注意:“->”和“.”运算符具有相同的优先级与结合性。在这种情况下,运算符 “.”不能用“->”来代替。 例如: struct date{ int day; char *month; int year; }birthday={14,“Sep”,1951}; struct employee{ char name[20]; double salary; long int tel; char sex;struct date *q; }person1={“H.Y.Jiang”,960.86,6634107},*p=&person1; #include <stdio.h> main( ) { p->q=&birthday; p->sex=‘M’; printf(“Name:%s\nsex:%c\nDateOfBirth:%2d .%s .%4d\n Tele.No:%ld\n”,p->name, p->sex, p->q->day, p->q->month, p->q->year, p->tel); } 公用体 5 . 5 公用体
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有