repositories
/
TD_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TP 11 exo2: avoid a function run at each for() loop iteration
[TD_C.git]
/
TP_11
/
exo2
/
ui.c
diff --git
a/TP_11/exo2/ui.c
b/TP_11/exo2/ui.c
index 998b8469cb4a45fbb503e8ca895b1b0d49e508fd..b8233b55175a5746e5f5e876db486c9e41f8d5e5 100644
(file)
--- 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) {
}
void displayList(link_t* head) {
- unsigned i = 0;
-
printf("--Begin--\n");
printf("--Begin--\n");
- while (head != NULL) {
- printf("value at [%d]=%d\n", i, head->value);
- head = head->next;
- 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");
}
}
printf("--End--\n");
}