From: "John M. Aldrich" 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Mad 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. | ---------------------------------------------------------------------