Better way to delete one line from file
I have a little database I have created for my program's purposes and an option in my program is to remove a line from the database. The database is just a text file with a .dat extension so it is easily extracted with the getline() function. Anyways what I do is just re-read the whole file and exclude the line the user wants to remove. Then I erase the file's contents and rewrite all the lines that I stored into my buffer, the buffer should have all the lines except the excluded one. Then I just recreate my file and fill it with the buffer's contents. This method of doing this seems excessive and unnecessary to me. My question is, are their better more efficient ways of going about this? Thanks.