TP11 exo2: Respect the specification for displayList() function
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 7 Mar 2017 19:40:32 +0000 (20:40 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 7 Mar 2017 19:40:32 +0000 (20:40 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP_11/exo2/ui.c

index 998b8469cb4a45fbb503e8ca895b1b0d49e508fd..7599780b4a88f37ade741213b249de17eca19ba0 100644 (file)
@@ -17,13 +17,9 @@ void displayArray(const int array[], unsigned length) {
 }
 
 void displayList(link_t* head) {
-    unsigned i = 0;
-
     printf("--Begin--\n");
-    while (head != NULL) {
-        printf("value at [%d]=%d\n", i, head->value);
-        head = head->next;
-        i++;
+    for (unsigned i = 0; i < list_count(head); i++) {
+        printf("value at [%d]=%d\n", i, list_get(head, i));
     }
     printf("--End--\n");
 }