review
struct student
{
int ID;
char name[32];
//next存储的是下一个结点的地址
struct student *next ;
};
//头结点
//指针head指向malloc得到的空间的地址赋,用于存放数据
//头结点的数据域为空,指针域存放的是下一个结点的地址!!!
struct student head = (struct student)malloc(sizeof(struct student ));
head->next = NULL;
//要插入的结点
struct student head = (struct student)malloc(sizeof(struct student ));
temp->ID = 12;
struct(temp->name,"zhang");
temp->next = NULL;
//因next存储的是第一个结点的地址,故访问到next,就可以访问到
//下一个结点
//将要插入的结点链接头结点之后
temp->next = head->next;
//重新定向头结点的下一个结点的地址
head->next = temp;
//temp所指向的空间已经添加 链表上,为防止其成为野指针,
//故将其置空
temp = NULL;
2.无头链表
3.双向链表
pre:前驱指针
next:后继指针
D:数据域
网友评论