Mail Archives: djgpp/1998/05/09/14:31:58
At 09:29 5/8/1998 +0200, JOA wrote:
>Hello.
>When i make a program (i want print a rand number into the screen) whit this
>function or random function,and execute it a few times the random numbers
>donīt change.
>The function randomize() isn`t in the help of Rhide.
>Thanks
In DJGPP (and other ANSI systems), the function to seed the random number
generator is `srand'. I think this was inadvertently omitted from the
documentation in DJGPP 2.01, but what it does is to seed the RNG with its
argument. If you want actual random numbers, you need to use some value that
changes; `time(NULL)' is a good bet.
If you want to use `random' instead (a better RNG, but a less portable
interface), the corresponding function is `srandom'.
Nate Eldredge
nate AT cartsys DOT com
- Raw text -