www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/24/23:02:28

From: "Tony O'Bryan" <aho450s AT nic DOT smsu DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: randomize?
Date: Mon, 24 Nov 1997 19:31:21 -0600
Organization: Southwest Missouri State University
Lines: 17
Message-ID: <347A2A69.73DE@nic.smsu.edu>
References: <b187cd$10393b DOT 109 AT news DOT alberni DOT net>
Reply-To: aho450s AT nic DOT smsu DOT edu
NNTP-Posting-Host: clark.a45.smsu.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

wolfman AT cedar DOT alberni DOT net wrote:
> 
> I know that Borland C++ has a function called randomize() that starts a new random seed.
>  Is there a function like this in DJGPP.  If not, how can I start a new random seed?
> It's pretty dumb to suppozidly have random things going on when every time you run a
> program, the exact same thing happens.

You can seed the random number generator with the current time like
this:

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

int main(void)
  {
  srandom(time(NULL)); <-- this is the important line
  }

- Raw text -


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