Randomizing problem

Started by
1 comment, last by DrWatson 16 years, 2 months ago
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.
Advertisement
You should only be calling srand() once, at the beginning of your program. After that, just call rand().
That's it! Thank you very very much!

This topic is closed to new replies.

Advertisement