Mail Archives: djgpp/1996/06/18/14:48:56
Xref: | news2.mv.net comp.os.msdos.djgpp:5136
|
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Random numbers ...
|
Date: | Tue, 18 Jun 1996 07:14:47 -0700
|
Organization: | Alcyone Systems
|
Lines: | 25
|
Message-ID: | <31C6B9D7.22A82DEE@alcyone.com>
|
References: | <4q3o4g$b6o AT infoserv DOT rug DOT ac DOT be>
|
NNTP-Posting-Host: | newton.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Johan De Messemaeker wrote:
> I'm trying to port my old Borland-progs to the DJGPP compiler.
> But there's a line i can't figure out :
>
> int tmp;
> tmp = random(3);
>
> With Borland, no problemo, it compiles, with DJGPP version 2, nope ...
> What is it man ?
Pretty simple solution: random is not an ANSI C function and is not available
in any DJGPP libraries.
You should be looking at srand (to seed the randomizer) and rand. To get a
bounded number, say between 0 and n - 1 (which if I recall correctly is what
random does, but it's been a while since I've used Borland compielrs), use
rand()%n.
--
Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max AT alcyone DOT com
San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect
H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade
Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem
"Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_
- Raw text -