Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


random numbers in DJGPP


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 20 December 1999 - 06:48 PM

I know how the random(); function works but it generates the same numbers everytime you compile/run the program. Does anybody know if there is such a randomize() function in DJGPP too and how you could use it since I know DJGPP's Help is talking about initstate(unsigned seed, char *arg_state, int n) but I have no clue how to use that!

Thanks in advance,

-- Paul


Sponsor:

#2 Gromit   Members   -  Reputation: 144

Like
Likes
Like

Posted 20 December 1999 - 03:58 AM

You have to seed the random number generator with your clocks current milliseconds. That should give you a random enough number.

#3 Just6979   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 December 1999 - 06:48 PM

you should actually use the rand() function because it's more portable. to get the best possible random numbers (they are never truly random), you have to seed the random number generator every time the program starts. to do this #include . then somewhere at the beginning of your program, insert this: srand(time(NULL)) ;
this will seed the random number generator with the number of seconds (milliseconds maybe?)elapsed since midnight. this way your program will come up with different random number every time you run it.

------------------
-Justin





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS