若有以下定义和语句 struct a { int n,m;}; struct a st[3]={{1,20},{2,19},{3,21}}; struct a*p=st; 则以下错误的引用是

admin2009-02-15  19

问题 若有以下定义和语句    struct a    {  int n,m;};    struct a st[3]={{1,20},{2,19},{3,21}};    struct a*p=st;    则以下错误的引用是

选项 A、(p++)->n;
B、st[0].n;
C、(*p).n;
D、p=&st.m;

答案8

解析 可以用以下三种形式来引用结构体变量中的成员:结构体变量名.成员名、指针变量名 ->成员名和(*指针变量名).成员名。选项D)中“&st.m”取的是结构体中成员的地址而不是结构的地址。
转载请注明原文地址:https://kaotiyun.com/show/J0Xp777K
0

最新回复(0)