LS的看的蛮仔细.
我刚写了个小程序测试了一下.
#include "stdio.h"
#include "conio.h"
#include"malloc.h"
typedef struct node{
int data;
struct node *next;
}node ;
main()
{
node *head=(node *)malloc(sizeof(node));
head->next=NULL;
head->next->data=3;
printf("Hello, world%d\n",head->next->data);
getch();
}
#include "stdio.h"
#include "conio.h"
#include"malloc.h"
typedef struct node{
int data;
struct node *next;
}node ;
main()
{
node *r,*head=(node *)malloc(sizeof(node));
head->next=NULL;
r=head->next;
head->next->data=3;
printf("Hello, world%d %d\n",head->next->data,r->data);
getch();
}
总结:我认为.既然已经给r一个指针,它的初始化为空,但不能就判断它就是空指针了.两者是有区别的.不知道我这样解释对不对.
谢谢关注.请大家以后多提意见.