Hello, i am making a library program that can store books and their information, eg.. Title, author.. to a text file. My problem is how can i edit the text file content or delete a line.
This is what the text file look like:
The C++ Programming Language
Bjarne Stroustrup
The C Programming Language 2nd Edition
Daniel Kerninghan & Dennis Rithcie
What if i want to replace Line 2 with something else? How do i do that..
By the way this is my addBook() function:
This works correctly but as i said how can i edit file content?
You can use an STL object, an array, (if you know the size) or write your own linked list.
At the beginner level, (unless your instructor tells you not to) I would suggest using a vector. Vectors can be dynamically resized, randomly accessed, and have convenient member functions.
Another methode would be to use the getline(istream&, string&), and write a new file, then erase the old.