title: C++ Console Application1.exe has triggered a breakpoint,Visual Studio 2015.Array and random numbers
body: <p>I'm trying to run this code in <code>VS 2015 c++</code>, but I have this problem: while getting the correct answer, I also get the error <code>C++ Console Application1.exe has triggered a breakpoint</code>. My task is to randomly choose 10 numbers between 1 and 50, show these numbers and sort them by odd and even numbers. Thanks in advance.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;ctime&gt;
  using namespace std;
  void main() {
      const int size = 10;
      srand(time(NULL));
      int arr[size], odd = 0, even = 0;
      for (int i = 0; i &lt; size; i++)
      {
          arr[i] = rand() % 50 + 1;
          cout &lt;&lt; arr[i] &lt;&lt; '\t';
      }
      cout &lt;&lt; endl;
      int *arrOdd = new int[odd];
      int *arrEven = new int[even];
      for (int i = 0; i &lt; size; i++)
      {
          if (arr[i] % 2 == 0) {
              arrEven[even] = arr[i];
              even++;
          }
          else
          {
              arrOdd[odd] = arr[i];
              odd++;
          }
      }
      int a = 0, b = 0;
      for (int i = 0; i &lt; size; i++)
          if (arr[i] % 2 == 0) {
              cout &lt;&lt; "arrEven = " &lt;&lt; arrEven[a] &lt;&lt; endl;
              a++;
          }
  
          else
          {
              cout &lt;&lt; "arrOdd = " &lt;&lt; arrOdd[b] &lt;&lt; endl;
              b++;
          }
  
      system("pause");
  }
  </code></pre>