Originally Posted by
Tibo-88
The problem is you "listset_add" function. In fact, what you do is attaching the last node to the first (which is ok if you want to do circular linked list), and then attaching the first one to the last, which means that your linked list will only be able to contains 2 elements, since you're always overwriting the "->next" of the head. So actually when you're printing "s->head->next->next->key" you are printing the first element. What you have to do in your "listset_add" function is :
->iteratate to the last element (for a circular linked list you iterate until the "->next" is equal to the head).
->link the last element to the new node.
->link the new element to the head (for circular list again).
Also, why are you using this "dummy" node in your initialization? Do you really want to insert this useless node each time you create a list set? You could set the head to NULL and check in you're "list_add" function if the head is NULL, and create it if yes.