title: Variable Sized Arrays vs calloc in C
body: <p>On the discussion of dynamic memory here: <a href="http://theocacao.com/document.page/234" rel="nofollow noreferrer">"Intro to C Pointers and Dynamic Memory"</a></p>
  
  <p>The author states:</p>
  
  <blockquote>
    <p>A memory block like this can effectively be used as a more flexible array. This approach is actually much more common in real-world C programs. It's also more predictable and flexible than a "variable size array"</p>
  </blockquote>
  
  <p>The type of memory block he is talking about is as such:</p>
  
  <pre><code>const int size = 5;
  int * array = calloc(size, sizeof(int));
  </code></pre>
  
  <p>and then using another pointer to iterate over the array:</p>
  
  <pre><code>int * index = array;
  for (i = 0; i &lt; size; i++) {
      *index = 1; // or whatever value
      index++;
  }
  </code></pre>
  
  <p>My question is how is this method better than a standard variable sized array like this?:</p>
  
  <pre><code>int array[variable];
  </code></pre>
  
  <p>or dynamic:</p>
  
  <pre><code>char name[] = "Nick";
  </code></pre>
  
  <p>The author doesn't really shed much light as to why I should prefer the former method to the latter. Or more specifically: How is it more "predictable and flexible"?</p>