Random number

closed account (jwkNwA7f)
Hello, I am making a guessing game where you have to guess a number. I can make a random number, but I want the number to stay the same each time you play. So it won't change each time someone plays, and so I can play too without knowing the answer.
Last edited on
Have you considered storing the generated value in a variable?
 
unsigned int correct_answer = rand();


And then you can have your game loop start after generating your value.
closed account (jwkNwA7f)
Yes, I had, but I have been using srand(time(NULL));.

I guess that is why it was changing each time I used it.

Thank you for your help!
Topic archived. No new replies allowed.