12-31-2011 07:03 PM
I generate random numbers (20 of them) and write them to output file.
It works fine (all 20 numbers are different) but everytime I run the program it outputs the same set of random numbers.
num1 = Random (1, 999);
num2 = Random (1, 999);
I need a new set of random numbers everytime I run the program. How do I do t
Solved! Go to Solution.
12-31-2011 08:02 PM
You must initialize the random number generator to a different value each time so that the sequence of (pseudo)random numbers is different. The function to use is SetRandomSeed. A simple way to initialize it each time with a different seed is to use the timer: SetRandomSeed (0);
01-01-2012 03:10 AM
Yes, that works,
Thanks.