From 8b200c099fe3ae84a482ba63135f54fa6c37a7e6 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Sun, 29 May 2022 18:23:10 +0100 Subject: [PATCH] switch from size_t to int for arr sizes --- src/bsrch.c | 4 ++-- src/bsrch.h | 2 +- src/bubble.c | 2 +- src/bubble.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bsrch.c b/src/bsrch.c index 58ec694..fabf8ed 100644 --- a/src/bsrch.c +++ b/src/bsrch.c @@ -11,10 +11,10 @@ #include -int bsrch(int target, int* arr, size_t n) +int bsrch(int target, int* arr, int n) { // TODO: Find a way to error if list is out of order - int start = 0, end = (int)n - 1; + int start = 0, end = n - 1; if (arr[start] > target || arr[end] < target) return -1; int mid = (start + end) / 2; diff --git a/src/bsrch.h b/src/bsrch.h index c4f683f..332cc1f 100644 --- a/src/bsrch.h +++ b/src/bsrch.h @@ -9,4 +9,4 @@ #include -int bsrch(int target, int* arr, size_t n); +int bsrch(int target, int* arr, int n); diff --git a/src/bubble.c b/src/bubble.c index 27d4ff6..39cdcb7 100644 --- a/src/bubble.c +++ b/src/bubble.c @@ -10,7 +10,7 @@ #include -void bubblesort(int* arr, size_t n) +void bubblesort(int* arr, int n) { bool swapped = true; diff --git a/src/bubble.h b/src/bubble.h index 0fd2700..e59a0bc 100644 --- a/src/bubble.h +++ b/src/bubble.h @@ -9,4 +9,4 @@ #include -void bubblesort(int* arr, size_t n); +void bubblesort(int* arr, int n);