Update the exercice skeleton Makefile to the one given during the
[TD_C.git] / TP_9 / exo2 / clist.c
index db081179bae025aa5d7ce1e9fd14e00d266c28e2..0ee532f36b283d0a8795cf2b10348bf066acfb15 100644 (file)
@@ -32,9 +32,10 @@ link_t* list_prepend(link_t* head, int value) {
 }
 
 unsigned list_count(link_t* head) {
-    int count = 1;
+    int count = 0;
     
-    if (head == NULL) { return 0; }
+    if (head == NULL) { return count; }
+    count = 1;
     while (head->next != NULL) {
         ++count;
         head = head->next;
@@ -44,7 +45,7 @@ unsigned list_count(link_t* head) {
 
 void list_set(link_t* head, unsigned index, int value) {
 
-    // FIXME: check for the index value validity
+    //FIXME: check for the index value validity
     for (unsigned count = 0; count < index; count++) {
         head = head->next;
     }