From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problems with djgpp 2.01 Date: Wed, 20 Nov 1996 19:07:05 -0800 Organization: Three pounds of chaos and a pinch of salt Lines: 27 Message-ID: <3293C759.31D5@cs.com> References: <9611202355 DOT AA06160 AT grupo DOT bfe 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: Goncalo Farias To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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. | ---------------------------------------------------------------------