cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/09/14:31:58

Mime-Version: 1.0
To: "JOA" <jsierra AT diandel DOT com>, djgpp AT delorie DOT com
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: PROBLEM WITH FUNCTION RAND()
Date: Sat, 9 May 1998 10:30:03 -0700
Message-ID: <19980509172947.AAH16984@ppp105.cartsys.com>

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 -


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