Random number generator functions (2003)

This commit is contained in:
kougyokugentou 2021-10-24 16:17:34 -07:00
parent 6ff439ccff
commit 683dc10c85
1 changed files with 21 additions and 0 deletions

21
demos/random.h Normal file
View File

@ -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 <stdlib.h> //These can either be uncommeted OR placed in your C file - Shaun
#include <time.h>
* 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));
}