I am new to STL and was trying a simple program to insert elements using push_back and trying to remove even indexed elements.
I took n elements and pushed it into the vector. But when I erase it I either get segmentation fault or some undesired output.
for(i=0;i<n;++i)
{
if(i%2==0)
v.erase(v.begin()+i);
}
If I use n-1 instead of n it works but does not give the desired output.