TP 11 exo2: avoid a function run at each for() loop iteration
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 8 Mar 2017 14:00:11 +0000 (15:00 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 8 Mar 2017 14:00:11 +0000 (15:00 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP_11/exo2/ui.c

index 7599780b4a88f37ade741213b249de17eca19ba0..b8233b55175a5746e5f5e876db486c9e41f8d5e5 100644 (file)
@@ -18,7 +18,7 @@ void displayArray(const int array[], unsigned length) {
 
 void displayList(link_t* head) {
     printf("--Begin--\n");
-    for (unsigned i = 0; i < list_count(head); i++) {
+    for (unsigned i = 0, length = list_count(head); i < length; i++) {
         printf("value at [%d]=%d\n", i, list_get(head, i));
     }
     printf("--End--\n");