title: generate random numbers and put them in an array
body: <p>I'm looking to write a little dice game called <a href="https://en.wikipedia.org/wiki/Farkle" rel="nofollow noreferrer">Farkle</a> (you may know it from Kingdom come delivarance) in C++ but I'm still learning, so I have some trouble with it. 
  atm I'm trying to roll 6 dice and put every rolled number in an array to be able to work with it afterwards. everything seem to work fine but Visual Studio ist outputting this error Code:</p>
  
  <blockquote>
    <p>Run-Time Check Failure #2 - Stack around the variable 'die' was corrupted.</p>
  </blockquote>
  
  <p>this is my code:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  
  
  void dice() {
      int die[5];
      int i = 1;
      while (i &lt;= 6) {
          die[i] = rand() % 6 + 1;
          cout &lt;&lt; die[i];
          i++;
      }
  }
  
  
  int main()
  {
      srand(time(NULL));
      dice();
      system("STOP");
      return 0;
  }
  </code></pre>
  
  <p>is ths actually the right approach for this kind of programm?</p>