设为首页 加入收藏

TOP

C语言双向循环链表api(源自gluster源码)(二)
2018-10-28 16:08:17 】 浏览:277
Tags:语言 双向 循环 api 源自 gluster 源码
new, sizeof(STU));
        new->num = i;
        new->score = i+1;
        strcpy(new->name, "2233");
        list_add(&new->student_list, &head->student_list);
    }
    /*删除指定的成员*/
    STU *pos=NULL;
    list_for_each_entry(pos, &head->student_list, student_list)
    {
        if(pos->num == 2){
            list_del(&pos->student_list);
            free(pos);
            pos = NULL;
            break;
            // printf("num:%d, score:%d, name:%s\n", pos->num, pos->score, pos->name);
        }
    }
    /*遍历链表*/
    list_for_each_entry(pos, &head->student_list, student_list)
    {
        printf("num:%d, score:%d, name:%s\n", pos->num, pos->score, pos->name);
    }
    return 0;
}


示例输出:


list only head
head->num:8, score:8, name:8888
num:4, score:5, name:2233
num:3, score:4, name:2233
num:1, score:2, name:2233
num:0, score:1, name:2233


截图:


C语言双向循环链表api(源自gluster源码)


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C语言实现的哈希表 下一篇Lua数据结构和内存占用分析

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目