title: Random numbers using system time all the same
body: <p>I have written a function in C++ that used the system time from <code>time.h</code> as a seed and returns a pseudo-random number between two specified values.
  </p>
  
  <pre><code>#include &lt;time.h&gt;
  
  int randInt(int min, int max)
  {
      int nSeed = time(NULL);
      int nRandom = nSeed * 13;
      nRandom = nRandom % (max + 1);
      nRandom += min;
      return nRandom;
  }
  </code></pre>
  
  <p>The function does exactly what it is supposed to do (as far as I can tell). However, when I repeatedly call the function, for example, when using a <code>for</code> loop to fill an array with pseudo-random numbers, almost no time has passed and therefore the seed is the same, making each number in the array the same. How could I solve this problem? Is there a way of getting a time from the system that is to a smaller precision? Or am I going about this completely the wrong way?</p>