So i'm working on a project, simple library system. I just don't know how to do this one thing.
Example, the user will input the following datas: title, book number and author.
My question is, 1) how do I output it to a .txt file 2) how can I edit that txt file afterwards and 3) how can I delete the txt file. I know it is through fstream, but i don't know how to do it.
Give some sample code if possible. Help is appreciated!
2. Editing a text file is trickier than programs like Notepad would have you believe. I recommend getting all the data from a text file, storing it somewhere, then clear the text file and write to it again. It appears writing with the truncate option will delete the content: