In a c++ file I'm writing for school I want to be able replace strings within a text file without altering the rest of the file.
Example from the text file (this an album database thing) with descriptions of what they are supposed to be in brackets:
AlbumA (name of album)
ArtistA (name of artist)
lost (stautus)
0 (location, int value)
AlbumB
ArtistB
damaged
1
my question is, how do I change, for example "ArtistA" to "Nightwish" without affecting the rest of the file. I've been using ifstream and ofstream commands. I've tried outputting a change with ofstream and it just deletes the rest of the file and writes in the change, and I know this won't accomplich what I want, but when I use ostream with ios::app it just slaps the change I want to make right on the end, messing up my database thingy, like so:
ArtistA
AlbumA
lost
0
AlbumB
ArtistB
damaged
1
Nightwish
As I said, this is for school, and is supposed to be written in c++, so please no comments telling me to use another program. Any other help is appreciated.