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.
Below is the code sample.
std::vector<int> V,Vx,Vy;
for (int i = 0; i < k; ++i)
{
cin>>x;
V.push_back(x);
}
for(int i=0;i<m-1;i=i+2)
{
Vx.push_back(V[i]);
}
for(int i=1;i<m-1;i=i+2)
{
Vy.push_back(V[i]);
}
for(int i=0;i<m-1;i=i+2)
cout<<Vx[i]<<endl;
Where am i doing wrong?? k=12, m=6