Mail Archives: djgpp/1997/01/10/21:39:57
: Is there a randomize() funtion for DJGPP? If so
: which Lib is it in? I keep getting the same #'s
: when I use the random() funtion, and I need
: to randomize the # seed.
I had the same problem, so I made my own. Here's what I use:
void randomize(void)
{
int num = (int) time(NULL);
if (num < 0)
num = -num;
srandom( num );
}
// Gets a random integer from 0 to top - 1.
int getRand(int top)
{
int num = (int) random();
if (num < 0)
num = -num;
return num % top;
}
Hope that helps,
Jason
=================================
Smile!!!!!!!
\|/
O O
-----ooooO----( )----Ooooo-----
O
And Have a Grrrrrrreat Day!!!!!!!
=================================
- Raw text -