runtime error with vector
When i run my code and type in a number into a variable and then check my vector to see if that number is present and if so delete it. However i keep getting an error with this segment of code spedifically the if statement.
The vector has the numbers 1,2,3,4 inside and when i run the code if i enter 2i get a runtime error saying the vector subscript is out of range? any ideas?
cin >> Age;
for(unsigned int i=0;i<=(names.size());i++)
names.erase((names.begin() + i));