From 683dc10c8590751177d79a9df3da0a9059d9f732 Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Sun, 24 Oct 2021 16:17:34 -0700 Subject: [PATCH] Random number generator functions (2003) --- demos/random.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 demos/random.h diff --git a/demos/random.h b/demos/random.h new file mode 100644 index 0000000..c030012 --- /dev/null +++ b/demos/random.h @@ -0,0 +1,21 @@ +/* This code is by Shaun Marquardt and licenced by GPLv2 + * + * to use these random number stuff, you MUST include the following in your prog: + +#include //These can either be uncommeted OR placed in your C file - Shaun +#include + +* Of course, remember to include this file! */ + +int rnd(int range); +void seedrnd(void); + +int rnd(int range) +{ + return(rand()%range); //spit up random num 0-range +} + +void seedrnd(void) //Seed the randomizer +{ + srand((unsigned)time(NULL)); +}