title: Random number function not properly randomizing (C++)
body: <p>So I'm trying to create this program which randomly generates a 10 x 10 matrix of random integers from 0 - 2. The problem is the program always gives the same set of numbers. Here's the code:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  
  using namespace std;
  
  int mapDraw(int array[], int mapMax, int mapBound){
      for(int i = 0; i &lt;= (mapMax - 1); i++){
          if((i % mapBound)==0){
              cout &lt;&lt; endl;
          }
          cout &lt;&lt; array[i];
      }
      return 0;
  }
  
  int main(){
      int mapx = 10;
      int mapz = mapx;
      int mapArea = mapx * mapz;
      int store[mapArea];
      for(int i = 0; i &lt;= (mapArea -1); i++){
          int height = rand() % 3;
          store[i] = height;
      }
      mapDraw(store, mapArea, mapx);
      return 0;
  }
  </code></pre>
  <p>When I run the code it always gives me this:</p>
  <blockquote>
  <p>2211210012</p>
  <p>2210121200</p>
  <p>0020110222</p>
  <p>2020012110</p>
  <p>2020020121</p>
  <p>2210012011</p>
  <p>1220011211</p>
  <p>2020120002</p>
  <p>0201021221</p>
  <p>0021212002</p>
  </blockquote>
  <p>For some reason it continues to give me the same out put after running the program multiple times. I would love some help and I have a hunch it will give you a different matrix when you run it on your machine so please try running it multiple times to see if the result is the same on consecutive runs. Thanks for the help in advance!</p>