I use this function to create random numbers between 100000000 and 999999999
< Code> int irand (int start, int stop) {double range = stop - start + 1; Return Start + (Int) (Range * Rand () / (RAITMX + 1.0)); }
When I use it this way, it is working properly
while (1) {DWORD dw = irand (100000000, 999999999); Printf ("dynamic key:% d \ n", dw); Sleep (100); }
But when I use this function without (1), I always get the same number. What do I need to fix?
The random number generator will need to get priority with some source of the antwerp for you. To see, the initial bead value of 1
is otherwise used by the rand
function. In your case, call srand (time (zero));
The first irand
function is said to be the first time that the move should be done. You can find this question useful:
Comments
Post a Comment