65,210
社区成员
发帖
与我相关
我的任务
分享node* p = null;
q->next=p;
那么q是是指向p节点,p指向null;还是q指向null,而p就是null;
q不是null,q的下一个是null
不是q的next等于空吗?
#include <stdio.h>
#define null 0
typedef struct s_node {
int val ;
struct s_node *next;
} node;
int main() {
node n,*q;
q=&n;
node *p = null;//定义一个指针变量p,指向node类型,并初始化其值为null
q->next = p;//将指针变量q所指向的node结构中的next成员的值赋值为p的值,即null
printf(" &n,q:%p\n", q );
printf(" &q:%p\n",& q );
printf(" &p:%p\n",& p );
printf(" p:%p\n", p );
printf("&(q->next):%p\n",&(q->next));
printf(" q->next :%p\n", q->next );
return 0;
}
// &n,q:0115FE28
// &q:0115FE20
// &p:0115FE24
// p:00000000
//&(q->next):0115FE2C
// q->next :00000000
//