Random number generator functions (2003)
This commit is contained in:
parent
6ff439ccff
commit
683dc10c85
21
demos/random.h
Normal file
21
demos/random.h
Normal 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));
|
||||
}
|
Loading…
Reference in New Issue
Block a user