So I am a bit bored, and I decided to make a nice easy game of "mastermind", a game where you have to guess 4 numbers, in the correct order. After a select amount of guesses, usually 10 attempts, you either guess right and win, or you lose if you go over 10.
The limiting of the number of guessing is the easy part. What I am having trouble with is the actual number. Having a set number was boring and easy to guess.
So my question is simple, how do I take a rand, and keep that one number and use it as the number I need to guess, but at the same time make it so that each time I re-load the game?
this function make random number between min and max value and print it to the output
1 2 3 4 5 6 7 8 9 10
void random (constint & __min, constint & __max) {
unsigned seed = (int)time(NULL);
srand(seed);
int range = __max - __min + 1;
int r = 0;
for (int i=0; i < 10; i++) {
r = rand() / 100 % range + __min;
cout << r << endl;
}
}