title: Why does creating an array with a size entered by the user work?
body: <p>From what I've learned, arrays cannot be variably sized in C++. For example,</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
      int size;
      cout &lt;&lt; &quot;How big is the array?\n&quot;;
      cin &gt;&gt; size;
      
      int array[size];
      array[0] = 2;
      cout &lt;&lt; array[0] &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  <p>The code above should not compile, because the size of an object in stack-based memory must be constant, and it should be known at compile-time... right? However, the code I have here compiles and runs successfully.</p>
  <p>Why is it possible for me to set the size of an array to a non-constant variable/user input?</p>