title: Segmentation fault using Vector C++
body: <p>I am trying to separate all the values stored in a vector into two different vectors. But when i am printing value of any of the vectors it is throwing seg fault.</p>
  
  <p>Below is the code sample.</p>
  
  <pre><code>std::vector&lt;int&gt; V,Vx,Vy;
  
          for (int i = 0; i &lt; k; ++i)
          {
              cin&gt;&gt;x;
              V.push_back(x);
          }
          for(int i=0;i&lt;m-1;i=i+2)
          {
              Vx.push_back(V[i]);
          }
          for(int i=1;i&lt;m-1;i=i+2)
          {
              Vy.push_back(V[i]);
          }
          for(int i=0;i&lt;m-1;i=i+2)
              cout&lt;&lt;Vx[i]&lt;&lt;endl;
  </code></pre>
  
  <p>Where am i doing wrong??
  k=12, m=6</p>