Previously, these functions were not required. The file was opened for reading, the data was written to the vector, then the record was deleted in the vector and the file was overwritten.
Now the file is open for reading, writing and recording. And to carry out the algorithm described above, you need to use the functions seekg , seekp to set the cursor to the desired position. Here's the method, what's wrong?
void DBTextFileAdapter::remove(string login) { file->seekg(ios_base::beg); while (*file >> user._login >> user._password) { container.push_back(user); } for (vector<User>::iterator it = container.begin(); it != container.end(); ++it) { if (it->_login == login) //находим запись { container.erase(it); //удаляем запись break; } } file->seekp(ios_base::beg); //это не работает for (vector<User>::iterator i = container.begin(); i != container.end(); ++i) { *file << i->_login << " " << i->_password << endl; //перезапись } container.clear(); }