This commit is contained in:
2026-04-02 16:54:02 +02:00
parent a87b015d99
commit 472e8cc8ec
3 changed files with 183 additions and 4 deletions
@@ -13,7 +13,7 @@ struct list *list_append(struct list *l, int e)
new_node->data = e;
if(!l) return new_node;
while (tmp->next) tmp = tmp->next;
while (tmp->next != NULL) tmp = tmp->next;
tmp->next = new_node;
return l;
@@ -21,17 +21,17 @@ struct list *list_append(struct list *l, int e)
size_t list_count(struct list *l){
int nbr_nodes = 0;
if (!l) return nbr_nodes;
//if (!l) return nbr_nodes;
struct list *tmp = l;
//nbr_nodes ++;
while(tmp->next != NULL) {
while(tmp != NULL) {
nbr_nodes ++;
tmp = tmp->next;
}
return nbr_nodes + 1;
return nbr_nodes;
}