title: Malloc a 2D array in C
body: <p>Every time I allocate the memory for a 2D array first I create an array of <code>int**</code> and then with a for I allocate the memory for each element.</p>
  
  <p>For example:</p>
  
  <pre><code>int ** arr = malloc(N*sizeof(int *));
  for(i=0; i&lt; N; i++) arr[i] = malloc(M*sizeof(int));
  </code></pre>
  
  <p>Wouldn't be possible allocate the memory like:</p>
  
  <pre><code>int ** arr = malloc(N*sizeof(int[M]));
  </code></pre>
  
  <p>or</p>
  
  <pre><code>int ** arr = malloc(sizeof(int[N][M]));
  </code></pre>
  
  <p>in order to avoid the <code>for</code>?</p>