www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/21/02:13:46

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problems with djgpp 2.01
Date: Wed, 20 Nov 1996 18:39:20 -0800
Organization: Three pounds of chaos and a pinch of salt
Lines: 25
Message-ID: <3293C0D8.3839@cs.com>
References: <01bbd6f0$f0f67780$a40141c2 AT warzone DOT telepac DOT pt>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp211.cs.com
Mime-Version: 1.0
To: Mad <mad AT grupo DOT bfe DOT pt>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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