delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/06/10:15:27

From: abultman AT cs DOT vu DOT nl (Bultman AJ)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What does "srand" and "srandom" do?
Date: 6 Mar 1998 14:59:14 GMT
Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
Lines: 25
Message-ID: <6dp302$4c6$1@star.cs.vu.nl>
References: <34FFC3E3 DOT 8465FB75 AT mail DOT hitel DOT net>
NNTP-Posting-Host: sampan.cs.vu.nl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ahn Ki-yung (KYAGRD AT mail DOT hitel DOT net) wrote:
[snip]
: 
: What does this mean. I can't get any idea from the example.
: So I tried to find out the difference before calling the function
: "srandom"
: I tried several times but I couldn't find any difference!
: The return value of "random( )" was unpredictable all the time, before
: and after calling the functions "srandom". Please help me how to use
: this function.

actually it's very simple. if you use random without srandom, every time you
exucute the program you will get the same sequence of random numbers from
random. you can use srandom to get a different sequence of numbers from
random. Now if you somehow link the seed in srandom with the clock at
startup, your program will generate different random number sequences every
time you use it.

Regards,
  Arne
-- 
Groeten,
  Arne

--------------------------------------------------------------

- Raw text -


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