| delorie.com/archives/browse.cgi | search |
| Message-ID: | <34D50550.48ED@quantum.de> |
| Date: | Mon, 02 Feb 1998 00:29:20 +0100 |
| From: | Tom Chojnacki <chojnack AT quantum DOT de> |
| Reply-To: | chojnack AT quantum DOT de |
| Organization: | Quantum Software GmbH, Dortmund, Germany |
| MIME-Version: | 1.0 |
| To: | djgpp AT delorie DOT com |
| Subject: | random number in range |
Hi!
A little problem:
how can I get random number from a given range.
Is the following solution efficient or maybe there is any ready-made
function ?
long rnd(long low, long high)
{
long r;
srandom((int)time(0));
while (((r = random()) < low) || (r > high))
;
return r;
}
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |