Xref: news2.mv.net comp.os.msdos.djgpp:8003 From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP random blues Date: Tue, 27 Aug 1996 22:43:22 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 33 Message-ID: <3223DC7A.5EF5@cs.com> References: <01bb942b$d2fb26c0$0100007f AT hiway DOT co DOT uk DOT hiway DOT co DOT uk> <32234A74 DOT 14A2 AT mr DOT insa-tlse DOT fr> NNTP-Posting-Host: ppp228.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Lievre Ludovic wrote: > > Mark Gilbert wrote: > > > > I can't figure rand() and random() out. They both seem positively un-random > > giving out the same numbers every time. > > When you use rand(), you must initialize a 'seed' with srand. > Such a code initialize the seed with current time. > [snip] The code example given is probably clearer as: srand( (int) time( NULL ) ); Also, rand() and random() are two different functions, with random() being generally more random than rand(). However, you must use srandom() to seed random(), not srand(). For more details, look up these functions in "info libc". BTW. there is no 'randomize' function in DJGPP. John -- John M. Aldrich, aka Fighteer I -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W+>++ N++ o+ K? w(---) O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++ h!() !r !y+() ------END GEEK CODE BLOCK------