已知学生记录描述为: struct student { int no; char name[20],sex; struct { int year,month,day; } birth;

admin2009-01-15  23

问题 已知学生记录描述为:    struct student    {   int no;        char name[20],sex;        struct        { int year,month,day;        } birth;    };    struct student s;   设变量s中的“生日”是“1984年11月12日”,对“birth”正确赋值的程序段是(    )。

选项 A、year=1984;month=11;day=12;
B、s.year=1984;s.month=11;s.day=12;
C、birth.year=1984;birth.month=11;birth.day=12;
D、s.birth.year=1984;s.birth.month=11;s.birth.day=12;

答案8

解析 本题考查结构体变量的基本概念。引用结构体成员的方式为:
   结构体变量名.成员名
   “.”是“成员运算符”(分量运算符),如果成员本身又是一个结构体类型,则要用若干个成员运算符,一级一级地找到最低一级的成员。只能对最低级的成员进行赋值或存取以及运算,所以选项D)正确。
转载请注明原文地址:https://jikaoti.com/ti/SNK0FFFM
0

最新回复(0)