title: Memory allocation for array on Stack or Heap (C)
body: <p>Consider the following C code:</p>
  <pre class="lang-c prettyprint-override"><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
  
      int main() {
  
          int arrSize;
          scanf(&quot;%d&quot;, &amp;arrSize);
          printf(&quot;%d\n&quot;,arrSize);
  
          int *dynArr = (int *)malloc(sizeof(int)*arrSize);
          int arr1[arrSize];
  
          return 0;
      }
  </code></pre>
  <p>In the code above, <strong>arrSize</strong> is size of an array taken from the user input. I want to know if the following observations are correct:</p>
  <ul>
  <li><p><strong>dynArr</strong> is a dynamic array which is allocated in the memory during runtime on heap. Size of dynArr can be modified using <em>realloc</em> function.</p>
  </li>
  <li><p><strong>arr1</strong> is also allocated in the memory during runtime but is not dynamic (i.e. their size cannot be modified) and it is allocated on <em>Stack</em>.</p>
  </li>
  </ul>