delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/31/01:36:39

From: abarak AT iil DOT intel DOT com (Amit Barak)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Random numbers...
Date: 27 Aug 1997 16:22:00 GMT
Organization: Intel Israel (74) Ltd.
Lines: 49
Message-ID: <5u1k78$1vcs$2@ilnews.iil.intel.com>
References: <01bcaa71$4c08c200$0d5e4ec2 AT xyy> <5telqi$1ue$1 AT news DOT kode DOT net>
NNTP-Posting-Host: ilx214.iil.intel.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

that's b/c srand() changes the seed for rand() but not for random() ...
there is some other function to change the 'random()' seed,
can't recall now ;-(

HTH,

-amit.

Heathen (ah897 AT detroit DOT freenet DOT org) wrote:
: In article <01bcaa71$4c08c200$0d5e4ec2 AT xyy>, xyy AT infonie DOT be says...
: >
: >
: >Hi!
: >
: >
: >I still can't obtain truly random numbers with the srand(), random(), and
: >rand() functions, because, whatever the seed number i put in srand(), it is
: >_always the same results.
: >
: >What can i do about it ?
: >
: >        A+. Xyy.
: >
: >
: 
: Hey here's a neat trick I used with Borland's C++ 3.0 from awhile ago for Random 
: Number Generater:
: 
:             #include <dos.h>
: 
:             Main(){
:             
:             int Jims_Rand_Num;
:             gettime(&ti_hund);
: 
: // Not sure if this was time.ti_hund;  
: // But your referencing the time struct in DOS.H 
: 
:             Jims_Rand_Num = ti_hund;
:             
:             }
: 
: It's Been awhile so you may have to play with it but it's great because it returns a random 
: percentage.  and that can be broken down to random 1-10 etc.   
: 
: hope I helped!                   
: 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019