delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/06/04:45:38

From: Ahn Ki-yung <KYAGRD AT mail DOT hitel DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: What does "srand" and "srandom" do?
Date: Fri, 06 Mar 1998 18:37:42 +0900
Organization: Korea Telecom
Lines: 38
Message-ID: <34FFC3E3.8465FB75@mail.hitel.net>
Reply-To: 96046 AT mail DOT seoul-shs DOT seoul DOT kr
NNTP-Posting-Host: dor20326.kaist.ac.kr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I wonder what does these libc functions do ?
In the libc reference info file there are 3 random functions.
They are rand, random, srandom.
The function "rand(unsigned int)" is not found but there is a prototype
in "stdlib.h"

Anyway the info file says about the function srandom like this

> srandom
> =======
> Syntax
> ------
>     #include <stdlib.h>
>     int srandom(int seed);
>
> Description
> -----------
> This function initialized the random number generator (random.).
> Passing the same SEED results in `random' returning predictable
> sequences of numbers.
>
> Return Value
> ------------
> Zero.
>
> Example
> -------
>     srandom(45);

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.


- Raw text -


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