mirror of
https://github.com/RolandWH/ceesort.git
synced 2025-03-14 21:41:37 +00:00
using ccolour for error messages
This commit is contained in:
parent
db2bfd4ee0
commit
ecdcdc2821
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "src/ccolour"]
|
||||||
|
path = src/ccolour
|
||||||
|
url = https://github.com/RolandWH/ccolour.git
|
@ -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 "bsrch.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.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
|
#pragma once
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
@ -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 "bubble.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.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
|
#pragma once
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
1
src/ccolour
Submodule
1
src/ccolour
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 090d94e7cde01c970f042290811b751fc8fe25d0
|
@ -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 "bubble.h"
|
||||||
#include "bsrch.h"
|
#include "bsrch.h"
|
||||||
|
#include "ccolour/colour.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -7,6 +15,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
inline void quit_err(const char* msg)
|
||||||
|
{
|
||||||
|
ChangeColour(msg, RED_FOREGROUND, DEFAULT_COLOR, true);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isint(char* s)
|
bool isint(char* s)
|
||||||
{
|
{
|
||||||
for (int i = 0; s[i]; i++)
|
for (int i = 0; s[i]; i++)
|
||||||
@ -22,10 +37,7 @@ bool isint(char* s)
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
quit_err("ERROR: Must have at least one argument (number)\n");
|
||||||
puts("ERROR: Must have at least one argument (number)");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int* arr = malloc((argc - 1) * sizeof(int));
|
int* arr = malloc((argc - 1) * sizeof(int));
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user