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 have no idea why you are getting those results, but there are better ways in C++11:
#include #include int main() { auto rnd = std::default_random_engine(std::random_device{}()); std::uniform_int_distribution<> dis(1, 999); std::cout << dis(rnd) << '\n'; }