www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/26/21:17:44

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Seed for srandom()
Date: Thu, 26 Dec 1996 18:30:17 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 25
Message-ID: <32C334B9.1A2@cs.com>
References: <32c2339c DOT 566606 AT news DOT eunet DOT fi>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp218.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Aleksi Kallio wrote:
> 
> What would be good seed  function for srandom()?
> Something clock based of course, but which one?
> I didn't find any time function that returns int value. And srandom
> requires int value.
> Any good ideas?

Cast the return value of time() to an int, like so:

#include <stdlib.h>
#include <time.h>

int main( void )
{
    srandom( (int) time( NULL ) );

    ...
}
-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I  |        fighteer AT cs DOT com         |
| Plan:  To find ANYONE willing to |   http://www.cs.com/fighteer   |
| play Descent 2 on DWANGO!        | Tagline: <this space for rent> |
---------------------------------------------------------------------

- Raw text -


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