From 66238736d8240b58f3f4b916a8eb243ae8ada22b Mon Sep 17 00:00:00 2001 From: juan Date: Thu, 16 Dec 2021 08:50:11 +0800 Subject: [PATCH] change the array initialization --- semester1/pset13/2-3-ArrayEX.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/semester1/pset13/2-3-ArrayEX.c b/semester1/pset13/2-3-ArrayEX.c index 3750b5d..767b97d 100644 --- a/semester1/pset13/2-3-ArrayEX.c +++ b/semester1/pset13/2-3-ArrayEX.c @@ -32,10 +32,11 @@ int main(void) { } void sort(char **arr, int n) { + char *tmp; for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (strcmp(arr[j], arr[j + 1]) > 0) { - char *tmp = arr[j]; + tmp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tmp; }