TP 13 exo1: Implement all the required features.
[TD_C.git] / TP_13 / exo1 / lib / utils.c
1 #include <stdio.h>
2
3 #include "utils.h"
4
5 void swap_int(int* v1, int* v2) {
6 int tmp = *v1;
7 *v1 = *v2;
8 *v2 = tmp;
9 }
10
11 void swap_ptr(void* v1, void* v2) {
12 void* tmp = v1;
13 v1 = v2;
14 v2 = tmp;
15 }
16
17 void handle_prompt_error(int errno) {
18 if (errno != 0) {
19 printf("\nMerci de saisir un nombre entier, exiting\n");
20 /* it's somewhat violent but better than looping forever */
21 exit(EXIT_FAILURE);
22 }
23 }