TP 11 exo2: Reorganize the directories structure to make use of the
[TD_C.git] / TP_11 / exo2 / lib / ui.c
diff --git a/TP_11/exo2/lib/ui.c b/TP_11/exo2/lib/ui.c
new file mode 100644 (file)
index 0000000..b8233b5
--- /dev/null
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+#include "ui.h"
+
+int promptValue(const char* msg, int* result) { 
+    puts(msg); 
+    int retVal = scanf("%d", result); 
+    return (retVal == 1) ? 0 : 1; 
+}
+
+void displayArray(const int array[], unsigned length) {
+    printf("--Begin--\n");
+    for (unsigned i = 0; i < length; i++) {
+        printf("array[%d]=%d\n", i, array[i]);
+    }
+    printf("--End--\n");
+}
+
+void displayList(link_t* head) {
+    printf("--Begin--\n");
+    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");
+}