From 44774f35828bac2024850d143701594796a08adb Mon Sep 17 00:00:00 2001 From: Tibor Bizjak Date: Wed, 19 Jul 2023 11:21:16 +0200 Subject: [PATCH] moved #includes --- k&r/05-pointers-and-arrays/05-07-sort.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/k&r/05-pointers-and-arrays/05-07-sort.c b/k&r/05-pointers-and-arrays/05-07-sort.c index e0c9521..ba74c55 100644 --- a/k&r/05-pointers-and-arrays/05-07-sort.c +++ b/k&r/05-pointers-and-arrays/05-07-sort.c @@ -1,6 +1,4 @@ #include -#include -#include /* array bounds */ #define MAXLINES 100 @@ -30,7 +28,9 @@ int main() } /* ---------- reading/printing functions */ -#include +#include +#include + /* writelines: prints n lines */ void writelines(char *lines[], int n) { @@ -76,13 +76,9 @@ int readlines(char *lines[], int maxlines, char *buffer, size_t buff_size) } /* ---------- string quicksort */ -/* swap: swap v[i] and v[j] */ -void swap(char *v[], int i, int j) -{ - char *temp = v[i]; - v[i] = v[j], v[j] = temp; -} +#include +void swap(char *v[], int i, int j); /* qsort_string: sort v[left]...v[right] into increasing order */ void qsort_string(char *v[], int left, int right) @@ -103,3 +99,11 @@ void qsort_string(char *v[], int left, int right) qsort_string(v, last+1, right); } +/* swap: swap v[i] and v[j] */ +void swap(char *v[], int i, int j) +{ + char *temp = v[i]; + v[i] = v[j], v[j] = temp; +} + +