TP 13 exo2: Implement the missing bits to do a full game.
[TD_C.git] / TP_13 / exo1 / lib / io.c
index e5a300070d24305638d8f140b866b480950a93d6..69b13d768f2b68e4cd0a01e01f2e23ab30a8368a 100644 (file)
@@ -1,9 +1,9 @@
+#include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
 
 #include "io.h"
 #include "array.h"
-#include "utils.h"
 
 int prompt_value(const char* msg, int* result) {
     puts(msg);
@@ -108,6 +108,14 @@ void do_resize(int array[], unsigned* old_size) {
     *old_size = new_size;
 }
 
+void handle_prompt_error(int errno) {
+    if (errno != 0) {
+        printf("\nMerci de saisir un nombre entier, exiting\n");
+        /* it's somewhat violent but better than looping forever */
+        exit(EXIT_FAILURE);
+    }
+}
+
 void display_array(int array[], unsigned size) {
     if (array != NULL) {
         printf("\n--array begin--\n");