How often should someone call srand()? Is it worth it to call it more than once? For example before each call to rand() or after x time.
Thanks for your time
You should only call it once.
I would urge you to consider using <random> if you are using modern C++, or boost::random if you are not, in place of srand()/rand(). They are a little more complex, but they can be used in a thread-safe manner (one generator per thread).
Thank you for your answers. I'll give <random> a try.
as a side note, you can use these things as a hash function, reseed off each record's key and get the first value. That will always give you the same value for the same key. This has limited usefulness give <map> but it is occasionally handy if you don't feel like writing a real hash function.
I can't think of any other reason to re-seed for most applications. Only if you want a new stream that you can control (know it will be the same sequence for debugging or other reasons) do you need to re-seed.