@@ -2,6 +2,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct list *list_append(struct list *l, int e)
|
||||
{
|
||||
struct list *tmp = l;
|
||||
@@ -30,7 +31,7 @@ size_t list_count(struct list *l){
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return nbr_nodes;
|
||||
return nbr_nodes + 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@ void list_print(struct list *l){
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
/*
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct list *l = NULL;
|
||||
@@ -174,10 +175,13 @@ int main(void)
|
||||
// l = [1] -> [2] -> [3]
|
||||
list_insert(&l, 1, 99); // l = [1] -> [99] -> [2] -> [3], and list_insert returns 0
|
||||
list_insert(&l, 9, 99); // list unchanged, returns 1
|
||||
list_print(l);
|
||||
list_count(NULL); // 0
|
||||
printf("count : %li\n",list_count(l)); // 3
|
||||
|
||||
|
||||
list_destroy(l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user