Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

random numbers in DJGPP

This topic is 6567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites