title: Set size of vector of vectors at run time
body: <p>I would like to know, how to set the size of vector of vectors at run time. </p>
  
  <p>If I have fixed size, i usually do it by </p>
  
  <pre><code>std::vector&lt;std::vector&lt;int&gt;&gt; ref(5);
  </code></pre>
  
  <p>and i push the elements in the specific vector by </p>
  
  <pre><code>ref[i].push_back(23); // i = 0,1,...4
  </code></pre>
  
  <p>Now if am interested to set the size at run time, means, i want to get size through command line argument, and push the elements in the same way as above.</p>
  
  <p>I thought to do it by declaring the vector of vectors by keeping it open</p>
  
  <pre><code>std::vector&lt;std::vector&lt;int&gt;&gt; ref;
  </code></pre>
  
  <p>and then push the element</p>
  
  <pre><code>ref[i].push_back(23);
  </code></pre>
  
  <p>But I am sure to be wrong, as I get the error</p>
  
  <blockquote>
    <p>Segmentation fault (core dumped)</p>
  </blockquote>