The code is giving me the same number every time I run the program. I can't figure out why.
I looked up a tutorial on how to use the seed the generator properly, and for some reason my example won't work.
#include <iostream>
#include <random>
int returnRandomNumber(int to) {
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<> dist(0, to);
return dist(mt);
}
int main() {
int testNum;
for (int i = 0; i < 10; i++) {
testNum = returnRandomNumber(100);
std::cout << testNum << "\n";
}
}