delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/28/17:19:14

Date: Tue, 28 Jan 1997 16:10:54 -0600 (CST)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: djgpp <djgpp AT delorie DOT com>
Subject: Re: Random numbers
In-Reply-To: <5ck9gf$ft7$1@fizban.solace.mh.se>
Message-ID: <Pine.SUN.3.95.970128160722.26911A-100000@ernie.eecs.uic.edu>
MIME-Version: 1.0

For random numbers try using something like this:
put srandom((int)time(NULL)); at the beginning of your program if you do
not want to get the same number numbers each time you run your program and
to get a random number to some limit x use this
random() % x; which gives you random number from 0 to x-1;

About the program size try compiling with the -s option. It should be much
smaller, but not as small as from real mode compilers.

On Tue, 28 Jan 1997, Nils-Erik Svang[iso-8859-1] =E5rd wrote:

> I resently downloaded DJGPP and was thrilled.
> But I have some questions.
> *How do I get the random numbers within my own limit?
> =09I currently use this code:
> =09
> =09while(1)
> =09{
> =09=09tt=3Drandom();
> =09=09tt=3Dtt/10000000;
> =09=09if(tt<320)break;
> =09}
> =09List[loop]=3Dtt;
>=20
> =09Nice? no I dont think so, there must several other ways to get by=20
> =09this, or some command that I've missed. (random produces a random=20
> =09number between 0....MAXINT, I hope that the answer wont be to go=09
>  =09change in the *.h file.
>=20
> *Why are my compiled files so large?
> =09I've compiled a nice "little" starfield I've been working on.
> =09To my suprise the *.exe file was over 1.8Mb, bad news if you have=20
> =09a small hardrive. Can you decrease that value?
>=20
> *When I use delay(10); a warning message appears, it says error in=20
> declaration int delay(...); but it's void delay(); in the help files.
>=20
>=20
> It would be nice if someone could help me.
> /nisse
>=20

- Raw text -


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