title: dynamically allocated arrays with user input c++
body: <p>I want to have a mini function that allows the user to type a group of numbers, and each of them will be dynamically allocated into an array. For example:</p>
  
  <pre><code>int main()
  {
      int* x = NULL;
      int n, numbers;
      std::cin &gt;&gt; n;
      x = new int[n]
      for (int i=0;i&lt;n;i++){
          std::cin &gt;&gt; numbers;
          x[i] = numbers;
      }
  
  delete [] x;
  </code></pre>
  
  <p>So when the user types in</p>
  
  <pre><code>3
  </code></pre>
  
  <p>The user will be able to type in 3 numbers following that </p>
  
  <pre><code>3 1 2 3
  </code></pre>
  
  <p>I am trying to store the values 1, 2, 3 into an array so it will look like</p>
  
  <pre><code>[1, 2, 3]
  </code></pre>
  
  <p>but right now it's storing as</p>
  
  <pre><code>[123]
  </code></pre>
  
  <p>Anyway i can fix this? I'm new to C++ programming so I feel like there's an easy solution to this but i'm not sure how.. thank you!</p>