有以下定义和语句struct stu{int n;struct st *next;};static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;p=&a[0];,则值为6的表达式是A.p++->n B.p->n++ C.(*p).n++ D.++p->n求详解

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/08 15:30:26
有以下定义和语句struct stu{int n;struct st *next;};static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;p=&a[0];,则值为6的表达式是A.p++->n B.p->n++ C.(*p).n++ D.++p->n求详解

有以下定义和语句struct stu{int n;struct st *next;};static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;p=&a[0];,则值为6的表达式是A.p++->n B.p->n++ C.(*p).n++ D.++p->n求详解
有以下定义和语句struct stu{int n;struct st *next;};
static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;
p=&a[0];,则值为6的表达式是
A.p++->n B.p->n++ C.(*p).n++ D.++p->n
求详解

有以下定义和语句struct stu{int n;struct st *next;};static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;p=&a[0];,则值为6的表达式是A.p++->n B.p->n++ C.(*p).n++ D.++p->n求详解
D.其实是一个链表,p->n指的就是其中的值,p++则指向下一个元素.
A p++->n相当于(&a[0]->n),于是是5
B p->n++相当于(&a[0]->n)++,也是5
C (*p).n++相当于(a[0].n)++,结果也是5
D ++p->n相当于++(p->n),结果6