Message-ID: <3310CDBF.727D@pobox.oleane.com> Date: Mon, 24 Feb 1997 00:07:43 +0100 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: steve wilcox CC: djgpp AT delorie DOT com Subject: Re: not so random numbers References: <856730848 DOT 1887 DOT 0 AT slicksoft DOT demon DOT co DOT uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit steve wilcox wrote: > > hi im having probs creating random numbers in djgpp i have made a > define like so : > #define randomize() srand((unsigned)time(NULL)) > > and im my code i call randomize() first but i still dont get random > numbers using x = random()%100; > > anyone know whats wrong ? The DJGPP C library has two random numbers generators : rand() and random(). They are two different functions, not aliases for the same (random() being, I'm told, more random than rand(), but more expensive to compute). These two generators have different seeding functions : srand() for rand(), and srandom() for random(). If your code is just like what you wrote above, you are calling srand() to initialise rand() (this is ok) but then you call random(), which is not seeded. Either use srandom() in the randomize() function, or call rand() after (*not both* ;-)). Regards Francois