title: Heap corruption detected error in C++
body: <p>Here is my code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  
  using namespace std;
  
  int main() {
      int** arr=NULL;
      int num=0;
      cin &gt;&gt; num;
      int* big=NULL;
      arr = new int*[num];
      for (int i = 0; i &lt; num; i++) {
          arr[i] = new int[5];
      }
      big = new int[num];
  
      for (int i = 0; i &lt; num; i++) {
          for (int j = 0; j &lt; 5; j++) {
              while (1) {
                  cin &gt;&gt; arr[i][j];
                  if (arr[i][j] &gt;= 0 &amp;&amp; arr[i][j] &lt; 100)
                      break;
              }
          }
      }
  
      for (int i = 0; i &lt; 5; i++) {
          big[i] = 0;
      }
  
      for (int i = 0; i &lt; num; i++) {
          for (int j = 0; j &lt; 5; j++) {
              if (big[i] &lt; arr[i][j]) {
                  big[i] = arr[i][j];
              }
          }
      }
  
      for (int i = 0; i &lt; num; i++) {
          cout &lt;&lt; "Case #" &lt;&lt; i + 1 &lt;&lt; ": " &lt;&lt; big[i] &lt;&lt; endl;
      }
  
      delete[]big;
      for (int i = num-1; i&gt;=0; i--) {
          delete[]arr[i];
      }
      delete[]arr;
  
      return 0;
  }
  </code></pre>
  
  <p>When I run this code, it says that there are heap corruption error (heap corruption detected). I think it means that there are some errors at 'new' or 'delete' parts in my codes, but I cannot find them. I hope someone to answer. Thanks. </p>