title: How do I add elements to an empty vector in a loop?
body: <p>I am trying to create an empty vector inside a loop, and want to add an element to the vector each time something is read in to that loop.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  int main()
  {
     std::vector&lt;float&gt; myVector();
  
     float x;
     while(cin &gt;&gt; x)
        myVector.insert(x);
  
     return 0;
  }
  </code></pre>
  <p>But this is giving me error messages.</p>