Mail Archives: djgpp/1996/11/21/01:10:18
Goncalo Farias wrote:
>
> With version 2.00 i didn't had to use srand(). The same source would give
> random number even without using srand(). Something is different bettween
> these 2 versions.
It may have been a bug in the v2.00 version. Before I answered your
question I looked into the library source code for rand() and srand()
(in src/libc/ansi/stdlib/rand.c if you must know). The seed value for
the randomizer is a static global variable, which means it is _always_
initialized to zero when your program is run. I cannot think of any way
in which v2.00 could have handled the coding without initializing to
zero, unless it ran srand() by default in startup (a kludgy solution).
> Yep, i didn't saw the srand () function. I searched something a La Borland
> like randomize() :))
Randomize() is non-ANSI and was not ported from Borland, as equivalent
functions already exist. ;)
--
---------------------------------------------------------------------
| 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 -