title: C++ initializing an array with size from standard input
body: <p>When I need to store multiple values of same type in c++ I can use a vector or array. So far I have mainly only used vectors, but I have heard that arrays are faster to work with (read and write values). If this is true I would like to know how I could make an array with the size that I read from standard input. I currently use something like this:  </p>
  
  <pre><code>int N;
  cin &gt;&gt; N;
  vector&lt;int&gt; myVector(N);
  </code></pre>
  
  <p>I have tried:</p>
  
  <pre><code>int N;
  cin &gt;&gt; N;
  array&lt;int, N&gt; myArray;
  </code></pre>
  
  <p>but this gives me an error because:<br>
  error: the value of 'N' is not usable in a constant expression<br>
  I have also tried:</p>
  
  <pre><code>int N;
  cin &gt;&gt; N;
  int myArray[N];
  </code></pre>
  
  <p>This will compile, but when I try to ask for the size of this array (<code>myArray.size()</code>) to iterate over it with a for loop then I get an error:<br>
  error: request for member 'size' in 'myArray', which is of non-class type 'int [N]'  </p>
  
  <p><b>So should I replace vectors with arrays to make my code faster and if so the how should I do it?</b></p>