Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating Truly Random Numbers
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/8278907/generating-random-numbers-effectively">Generating random numbers effectively</a> </p> </blockquote> <p>I need to generate <code>random numbers</code> in my <code>C++</code> application. I know from reading these two articles --</p> <p><a href="http://www.cprogramming.com/tutorial/random.html" rel="nofollow noreferrer">http://www.cprogramming.com/tutorial/random.html</a></p> <p><a href="https://stackoverflow.com/questions/3786389/write-a-c-function-that-generates-one-random-number-or-a-pair-of-random-numbers/3786809#3786809">write a c function that generates one random number, or a pair of random numbers, or a triplet of random numbers given the particular ranges</a></p> <p>-- that random numbers can be generated using <code>srand()</code> and <code>rand()</code> but in both cases the current time according to the <code>system clock</code> is used as a <code>seed</code>. But I read in the first article that <code>rand()</code> will create the same random numbers if the seed is the same. So if two different users ran my application at the same time then they would have the same random numbers. Which would be pointless because I need the random numbers to be unique for the most part. (I know they cant be truly 100% unique if they are generated randomly)</p> <p>So my question is can I create a random seed not based on system time and if so how, why does <code>rand()</code> produce the same numbers with the same seed and is there a way to make <code>rand()</code> produce different numbers with the same seed, or is there any other way to generate random numbers?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload