old-c-code/demos/random.h

22 lines
488 B
C

/* 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));
}