void EmployeeSearch()
{
vector<string> file;
string temp;
ifstream infile("GROUP.txt");
while( !infile.eof() )
{
getline(infile, temp);
file.push_back(temp);
}
// done reading file
infile.close();
string item;
cout << "Enter an employee number to delete from the file: ";
getline(cin, item);
for(int i = 0; i < (int)file.size(); ++i)
{
if(file[i].substr(0, item.length()) == item)
{
file.erase(file.begin() + i);
cout << "Order erased!"<< endl;
i = 0; // Reset search
}
}
This code works fine and deletes the appropriate record when ran in its own program. However, when i implement this as a method within my class, it does not work and deletes every record in the file. Any help would be greatly appreciated.