1 | #include <limits.h> |
2 | #include <stdio.h> |
3 | #include <stdlib.h> |
4 | |
5 | int compare_ints(const void *a, const void *b) { |
6 | int arg1 = *(const int *)a; |
7 | int arg2 = *(const int *)b; |
8 | |
9 | // breakpoint 1 |
10 | |
11 | if (arg1 < arg2) |
12 | return -1; |
13 | if (arg1 > arg2) |
14 | return 1; |
15 | return 0; |
16 | } |
17 | |
18 | int main(void) { |
19 | int ints[] = {-2, 99, 0, -743, 2, INT_MIN, 4}; |
20 | int size = sizeof ints / sizeof *ints; |
21 | |
22 | qsort(base: ints, nmemb: size, size: sizeof(int), compar: compare_ints); |
23 | |
24 | for (int i = 0; i < size; i++) { |
25 | printf(format: "%d " , ints[i]); |
26 | } |
27 | |
28 | printf(format: "\n" ); |
29 | return 0; |
30 | } |