Ok so ive already looked up solutions to my problem and my teacher does not allow me to use a simple iterator for the delete instead this is a hard coded delete function. what this program does is ask the user for 10 numbers and creates a vector of size 10 it then sorts the numbers in ascending order. then my program asks the user what integer he/she would like to delete in the program. and if there are multiple instances of this number it deletes those as well. My finderase function uses a loop to go through and make comparisions using the erase function it works in some instances but heres were it gets weird it wont work if the number im looking to delete is the last number in the vector. im assuming its maybe my index is off by a few numbers under my finderase() function or something ive been working hard to find a solution any help would be appreciated

```
void erase(vector <int>& v,int pos) {
for (unsigned int c=pos; c < v.size() - 1; c++){
v[c] = v[c+1];
cout << v[c+1] << endl;
//cout << " v[" << c << "]= " << v[c] << endl;
}
v.pop_back();
}
//Function used to enter the integer and pass it to erase.
void finderase(vector<int>&v,int &num)
{
for(int i=0;i < v.size();i++){
while (num==v[i]){
erase(v,i);
}
}
}
int main()
{
//Size of the vector
//Variable for user to choose number to delete.
vector <int> betsy;
//Counter used for filling the vector and displaying it.
int z=0;
//Integer to store delete.
int del;
int userinput=0;
//Vector entry
for (int i=0; i < 10; i++){
cout << "Enter an integer into the vector";
cin >> userinput;
betsy.push_back(userinput);
}
cout << "Enter an integer to delete.";
cin >> del;
finderase(betsy,del);
//Prints the vector after the delete.
cout << "myvector contains:";
for (z=0; z < betsy.size(); z++){
cout << " " << betsy.at(z);
cout << endl;
}
return 0;
}
```