From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: real random numbers Date: Thu, 26 Mar 1998 18:24:00 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 25 Message-ID: <351AE390.2516@cs.com> References: <351634A2 DOT 5ACD AT hol DOT fr> <35169C99 DOT 3B53 AT pobox DOT oleane DOT com> <6fe13v$55q AT tuegate DOT tue DOT nl> NNTP-Posting-Host: ppp244.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 Precedence: bulk hat AT se-46 DOT wpa DOT wtb DOT tue DOT nl wrote: > > As some people already have pointed out, this only works when your > program runs at least for a single second. > Does somebody know how to take care of getting a different value each > time you run a program, no matter how often in a single second you start > it ? The header declares a function called gettimeofday() (q.v.). The struct returned by this function contains the current GTM time accurate to the millisecond. Unless your program runs faster than once every millisecond (very difficult to do on a DOS box), this value should be adequate to use as a seed. If you want to get really esoteric, when your program exits you could have it produce a random number, write it to disk, and then read it in the next time to use as the seed. -- --------------------------------------------------------------------- | John M. Aldrich |"Men rarely (if ever) manage to dream | | aka Fighteer I |up a god superior to themselves. Most | | mailto:fighteer AT cs DOT com |gods have the manners and morals of a | | http://www.cs.com/fighteer |spoiled child." - Lazarus Long | ---------------------------------------------------------------------