From: Jérôme Benoit Date: Tue, 7 Mar 2017 19:40:32 +0000 (+0100) Subject: TP11 exo2: Respect the specification for displayList() function X-Git-Url: https://git.piment-noir.org/?p=TD_C.git;a=commitdiff_plain;h=198615555e53390f89cab08e27faaaeb42c2ee6e TP11 exo2: Respect the specification for displayList() function Signed-off-by: Jérôme Benoit --- diff --git a/TP_11/exo2/ui.c b/TP_11/exo2/ui.c index 998b846..7599780 100644 --- a/TP_11/exo2/ui.c +++ b/TP_11/exo2/ui.c @@ -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"); }