using ccolour for error messages

This commit is contained in:
Roland W-H 2022-05-26 13:34:12 +01:00
parent db2bfd4ee0
commit ecdcdc2821
7 changed files with 48 additions and 4 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/ccolour"]
path = src/ccolour
url = https://github.com/RolandWH/ccolour.git

View File

@ -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 <stdbool.h>

View File

@ -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 <stddef.h>

View File

@ -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 <stdbool.h>

View File

@ -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 <stddef.h>

1
src/ccolour Submodule

@ -0,0 +1 @@
Subproject commit 090d94e7cde01c970f042290811b751fc8fe25d0

View File

@ -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 <ctype.h>
#include <stdbool.h>
@ -7,6 +15,13 @@
#include <stdlib.h>
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++)