How to implement a linked list in C?

后端 未结 14 848
予麋鹿
予麋鹿 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:31

    If you are learning C pointer theory this is a good exercise. Otherwise, it feels like too much indirection for code that is not generic (as in a library).

    Instead of allocating a static 128 byte character string, you might want to do some more pointer practice and use an allocated exact length string that you clean up at exit.

    Academically, kungfucraigs' structure looks more generic then the one you have defined.

提交回复
热议问题