From: George Foot Newsgroups: comp.os.msdos.djgpp Subject: Re: randomize? Date: 25 Nov 1997 05:28:49 GMT Organization: Oxford University, England Lines: 30 Message-ID: <65dnmh$1pk$3@news.ox.ac.uk> References: <347A2A69 DOT 73DE AT nic DOT smsu DOT edu> NNTP-Posting-Host: sable.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Mon, 24 Nov 1997 19:31:21 -0600 in comp.os.msdos.djgpp Tony O'Bryan wrote: : You can seed the random number generator with the current time like : this: : #include : #include : int main(void) : { : srandom(time(NULL)); <-- this is the important line : } ... but note that this seeds the `random()' generator. To seed the `rand()' generator, use `srand' instead of `srandom'. Also note that if you're from a Borland background you'll be expecting the `random' function to take a parameter (the smallest integer that will never be returned) -- in djgpp this is not the case. The `rand' function returns an integer from 0 to RAND_MAX and the `random' function returns an integer from 0 to MAXINT. In practice, these maxima are both the same, and equal to the largest number that can be expressed as a (32-bit) integer. To restrict the range of the numbers, use the divison-remainder operator, `%'. -- Regards, george DOT foot AT merton DOT oxford DOT ac DOT uk