How to implement a linked list in C?

后端 未结 14 893
予麋鹿
予麋鹿 2020-12-06 02:49

I am creating a linked list as in the previous question I asked. I have found that the best way to develop the linked list is to have the head and tail in another structure.

14条回答
  •  盖世英雄少女心
    2020-12-06 03:35

    You're calloc'ing space for your list_t struct, just pointers to list head and tail, which isn't what you want to do.

    When you add to a linked list, allocate space for an actual node in the list, which is your product_data_t struct.

提交回复
热议问题