I want to supply a number, and then receive a set of random numbers. However, I want those numbers to be the same regardless of which computer I run it on (assuming I supply the same seed).
Basically my question is: in C++, if I make use of rand(), but supply srand() with a user-defined seed rather than the current time, will I be able to generate the same random number stream on any computer?
srand()&rand()are not part of the STL. They’re actually part of the C runtime. Yes, they will produce the same results as long as it’s the same implementation ofsrand()/rand().Depending on your needs, you might want to consider using Boost.Random. It provides several high-quality random number generators.