美文网首页
SQSH1616 12-21 C基础

SQSH1616 12-21 C基础

作者: 彳亍的心 | 来源:发表于2016-12-21 19:15 被阅读0次

    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:数据域

    相关文章

      网友评论

          本文标题:SQSH1616 12-21 C基础

          本文链接:https://www.haomeiwen.com/subject/tqoqvttx.html