www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/01/02:32:29

From: Dantalion <dantalion AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: random numbers
Date: Thu, 01 Jan 1998 01:55:55 -0500
Organization: Pax Mortis
Lines: 14
Message-ID: <34AB3DFB.25A@hotmail.com>
Reply-To: dantalion AT hotmail DOT com
NNTP-Posting-Host: ts2-10.nj.cnct.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ok, I have a little problem here... it seems I can't get DJGPP to
generate a random number. I tried using something like srandom(34) then
using r=random() and printf("%d", r), but it would always give me a
large six or more digit number, and when I use rand() it would always
give me a zero. Say I wanted a random number from 1 to 10, how would I
do it? And also, how can I make it so that srandom takes a different
seed every time the program is run, so that I get a different number
each time?

Thanks for any help you can give.

-- 
Suddenly, I heard a tapping... as of someone gently rapping, rapping at
my chamber door. You heard me rapping, right?  --The Crow

- Raw text -


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