Mail Archives: djgpp/1996/11/21/02:13:46
Mad wrote:
>
> Hello all,
>
> i just downloaded djgpp version 2.01 and i'm having problem with the
> rand() function which always assigns 0 (zero) to my variable. For instance:
You must seed the random number generator with a call to srand() before
you use any random numbers in your program. The output of time(0) is
usually a good seed to use.
For a slightly better (less predictable) random number generator, use
random()/srandom().
Since this is going to the newsgroup, I have a comment for Eli/DJ: It
appears that, for some reason, srand() got left out of the libc.inf
documentation! Was this something deliberate, or just a mistake?
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com |
| * Proud user of DJGPP! * | http://www.cs.com/fighteer |
| ObJoke: If Bill Gates were a robber, not only would he |
| shoot you, but he'd send you a bill for the bullets. |
---------------------------------------------------------------------
- Raw text -