• Advertisement
Sign in to follow this  

Randomizing problem

This topic is 3678 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

I'm a beginner in C programming, I study it for 3 months now. Before that I was using Visual Basic 6 for about five years, so I know the basics. Anyway, I'm creating a little sokoban clone (my first game in C :D ) using SDL (just the basic library), and I've bumped into a problem: I need a fast-changing seed for srand() function. I need to get (maximum) 400 random numbers, as fast as possible, and the srand(time(0)) is just to slow, and I get all 400 numbers the same. So, I need some function that returns a proper number (that I can feed to srand) and does it fast. I tried google-ing for it, but nothing useful came up. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You should only be calling srand() once, at the beginning of your program. After that, just call rand().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement