From 1887bae82abf8dd9ff26516ae607ea3c69ce80cd Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 16 Jun 2024 11:57:58 -0400 Subject: [PATCH] Added random integer function... --- xtandard.c | 4 ++++ xtandard.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/xtandard.c b/xtandard.c index 844199b..7d3d76e 100644 --- a/xtandard.c +++ b/xtandard.c @@ -105,6 +105,10 @@ void fatal_failure (int condition, char * message) { } } +int random (int minimum, int maximum) { + return (rand () % (maximum - minimum + 1) + minimum); +} + void limit (int * value, int minimum, int maximum) { if (value == null) { return; diff --git a/xtandard.h b/xtandard.h index 9f2c0fa..266c4bb 100644 --- a/xtandard.h +++ b/xtandard.h @@ -81,6 +81,8 @@ extern void echo_byte (int byte); extern void fatal_failure (int condition, char * message); +extern int random (int minimum, int maximum); + extern void limit (int * value, int minimum, int maximum); extern void * allocate (int size);