After noticing that the rand() function produced the same output of 41 each time, I seeded the generator using srand(time(0)). That solved the problem of the recurring outpu
I recently ran across the same problem and found that Karoly Horvath's comment on your original question solved the issue, although it is a bit "hacky". I was seeing a predictable increase in return values, and after sticking another rand()
immediately after the srand()
, the problem went away. I ended up with this:
srand(time(NULL));
rand();
int seed = rand();
I'd like to figure out why this is happening...but in the meantime this works.