delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/22/21:48:11

Message-ID: <35662A33.9EB0FE7D@uol.com.br>
Date: Fri, 22 May 1998 22:45:23 -0300
From: "Juciê Dias Andrade" <jucie AT uol DOT com DOT br>
MIME-Version: 1.0
To: Jason Cain <jcain AT ti DOT com DOT SUCKS>
CC: djgpp AT delorie DOT com
Subject: Re: Random numbers in a certain range?
References: <3565ED8E DOT 18DE01B6 AT SPAM DOT ti DOT com DOT SUCKS>

Jason Cain escreveu:
> 
> Hello,
> 
> I'm trying to find a way to generate random numbers within a given
> range.  I want to generate a series of random points to draw on the
> screen, and so in my case I need to generate random numbers from 0...640
> and 0...480.

That's easy:
	rand() % 480	will fall betwen 0 and 479
	rand() % 640	will fall betwen 0 and 639.

I hope it helps.
[]s


- Raw text -


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