delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/23/11:39:02

Date: Wed, 23 Sep 1998 15:06:54 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <nate AT cartsys DOT com>
cc: Paul Minerva <p_minerva AT msn DOT com>, djgpp AT delorie DOT com
Subject: Re: problem with rand()
In-Reply-To: <360835F0.4750F448@cartsys.com>
Message-ID: <Pine.SUN.3.91.980923150616.1392o-100000@is>
MIME-Version: 1.0

On Tue, 22 Sep 1998, Nate Eldredge wrote:

> You don't say how it works incorrectly, but perhaps you mean the fact
> that it produces the same numbers every time.  This is because you
> aren't seeding the random number generator.  The numbers are actually
> generated as a series based on some initial value, and that value is the
> seed.  You set it with `srand', typically once at the beginning of your
> program.  The return value of `time(0)' is a good value to use.

Please note that this issue is now explained in the FAQ (section
22.22).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019