in reply to srand producing the same sequence of random numbers
You have greatly misunderstood the purpose of srand. This is not a bug. If you repeatedly call srand with the same seed, then you will get the same sequence of pseudorandom numbers from rand each time. That's what srand does.
If you want a different set of pseudorandom numbers each time, then forget that srand even exists. The first call to rand will automatically seed the PRNG with a value based on the system clock, which will get you close enough to actual randomness for most practical purposes.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: srand producing the same sequence of random numbers
by pemungkah (Priest) on Oct 12, 2010 at 21:04 UTC |
In Section
Seekers of Perl Wisdom