有以下定义和语句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/06/29 00:19:24
![有以下定义和语句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求详解](/uploads/image/z/3990519-63-9.jpg?t=%E6%9C%89%E4%BB%A5%E4%B8%8B%E5%AE%9A%E4%B9%89%E5%92%8C%E8%AF%AD%E5%8F%A5struct+stu%7Bint+n%3Bstruct+st+%2Anext%3B%7D%3Bstatic+struct+st+a%5B3%5D%3D%7B5%2C%26a%5B1%5D%2C7%2C%26a%5B2%5D%2C9%2C%27%5C0%27%7D%2C%2Ap%3Bp%3D%26a%5B0%5D%3B%2C%E5%88%99%E5%80%BC%E4%B8%BA6%E7%9A%84%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%98%AFA.p%2B%2B-%3En+B.p-%3En%2B%2B+C.%28%2Ap%29.n%2B%2B+D.%2B%2Bp-%3En%E6%B1%82%E8%AF%A6%E8%A7%A3)
有以下定义和语句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