diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..669e6ed --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/ccolour"] + path = src/ccolour + url = https://github.com/RolandWH/ccolour.git diff --git a/src/bsrch.c b/src/bsrch.c index 64cbfad..5b66f35 100644 --- a/src/bsrch.c +++ b/src/bsrch.c @@ -1,3 +1,10 @@ +/* + * Filename: bsrch.c + * Author(s): Roland (r.weirhowell@gmail.com) + * Description: Perform binary search on an integer array + * License: MIT (https://spdx.org/licenses/MIT.html) +*/ + #include "bsrch.h" #include diff --git a/src/bsrch.h b/src/bsrch.h index f464723..c4f683f 100644 --- a/src/bsrch.h +++ b/src/bsrch.h @@ -1,3 +1,10 @@ +/* + * Filename: bsrch.h + * Author(s): Roland (r.weirhowell@gmail.com) + * Description: Header file for bsrch.c + * License: MIT (https://spdx.org/licenses/MIT.html) +*/ + #pragma once #include diff --git a/src/bubble.c b/src/bubble.c index 7541f18..27d4ff6 100644 --- a/src/bubble.c +++ b/src/bubble.c @@ -1,3 +1,10 @@ +/* + * Filename: bubble.c + * Author(s): Roland (r.weirhowell@gmail.com) + * Description: Perform bubble sort on an array of integers + * License: MIT (https://spdx.org/licenses/MIT.html) +*/ + #include "bubble.h" #include diff --git a/src/bubble.h b/src/bubble.h index 39d0387..0fd2700 100644 --- a/src/bubble.h +++ b/src/bubble.h @@ -1,3 +1,10 @@ +/* + * Filename: bubble.h + * Author(s): Roland (r.weirhowell@gmail.com) + * Description: Header file for bubble.c + * License: MIT (https://spdx.org/licenses/MIT.html) +*/ + #pragma once #include diff --git a/src/ccolour b/src/ccolour new file mode 160000 index 0000000..090d94e --- /dev/null +++ b/src/ccolour @@ -0,0 +1 @@ +Subproject commit 090d94e7cde01c970f042290811b751fc8fe25d0 diff --git a/src/ceesort.c b/src/ceesort.c index cc357da..bcb27d2 100644 --- a/src/ceesort.c +++ b/src/ceesort.c @@ -1,5 +1,13 @@ +/* + * Filename: ceesort.c + * Author(s): Roland (r.weirhowell@gmail.com) + * Description: Main file to handle I/O and calling fucntions + * License: MIT (https://spdx.org/licenses/MIT.html) +*/ + #include "bubble.h" #include "bsrch.h" +#include "ccolour/colour.h" #include #include @@ -7,6 +15,13 @@ #include +inline void quit_err(const char* msg) +{ + ChangeColour(msg, RED_FOREGROUND, DEFAULT_COLOR, true); + exit(EXIT_FAILURE); +} + + bool isint(char* s) { for (int i = 0; s[i]; i++) @@ -22,10 +37,7 @@ bool isint(char* s) int main(int argc, char** argv) { if (argc < 2) - { - puts("ERROR: Must have at least one argument (number)"); - return -1; - } + quit_err("ERROR: Must have at least one argument (number)\n"); int* arr = malloc((argc - 1) * sizeof(int)); for (int i = 1; i < argc; i++)