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.