delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/26/19:06:51

From: "Jonas Kölker" <Jonaskoelker AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Randomness - good enough for dice games?
Date: Sun, 27 Jun 1999 00:25:26 +0200
Organization: Customer at Telia Danmark (http://www.telia.dk)
Lines: 12
Message-ID: <7l3k1u$2f1$1@news101.telia.com>
NNTP-Posting-Host: t1o106p84.telia.com
X-Trace: news101.telia.com 930435966 2529 194.255.244.84 (26 Jun 1999 22:26:06 GMT)
X-Complaints-To: abuse AT telia DOT dk
NNTP-Posting-Date: 26 Jun 1999 22:26:06 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi there!
I'm needing some real good and very random functions, and I've tried the
random(), but it just won't be random - always throws up the same result:

/* !!!not compilable!!! */
printf("%d",random()%100); //this always outputs 53 or something


This makes me wonder - does random() need some initialization to be random -
as srand(clock()) for rand() - or won't it work proper on my machine?


- Raw text -


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