X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_13%2Fexo1%2Flib%2Futils.c;h=5139bae1bccf69facf4748275a45c3da141732dd;hb=506ed8ed2ccf2fce58e9a0dd651e4ceea5a6320c;hp=c48206fed5be5edc6f7f4eab98eb383f1c1b5545;hpb=33b9c6461d00f013d692dde3c3f79f0b002ce564;p=TD_C.git diff --git a/TP_13/exo1/lib/utils.c b/TP_13/exo1/lib/utils.c index c48206f..5139bae 100644 --- a/TP_13/exo1/lib/utils.c +++ b/TP_13/exo1/lib/utils.c @@ -1,6 +1,8 @@ +#include + #include "utils.h" -void swap_int_ptr(int* v1, int* v2) { +void swap_int(int* v1, int* v2) { int tmp = *v1; *v1 = *v2; *v2 = tmp; @@ -11,3 +13,11 @@ void swap_ptr(void* v1, void* v2) { v1 = v2; v2 = tmp; } + +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); + } +}