Removing from Vector

Hi all, I am new to C++ programming.

I would like to remove an entry from a textfile.
My coding works fine with the reading portion from textfile, but I am stuck with the removing portion.

Below is my coding:

void OptionB :: DisplayCashFlow()
{

ifstream cashflow;
cashflow.open ("cashflow.txt");
string data;
while (! cashflow.eof())
{
getline(cashflow, data);
if (!cashflow.eof())
{
file.push_back(data);
}

}
cashflow.close();
string choice;
for(int i = 0; i < (int)file.size(); i++)
{
cout << i + 1 << ") " << file[i] << endl;
}

cout << "Enter which entry to remove" << endl;
cin >> choice;

if(i.substr(0, choice.length)) == choice)
{
file.erase(file.begin() + i);
cout << "Detail Deleted" << endl;
}


}
[code] "Please use code tags" [/code]
1
2
while( getline(cashflow, data) )
  file.push_back(data);


but I am stuck with the removing portion.
¿could you be more specific? Take a look at http://www.cplusplus.com/reference/algorithm/find/
Topic archived. No new replies allowed.