I am learning I/O, using fstream to read and write to files. If I have a file that already has data in it, and I want to change some of that data, what mode do I use?? eg. to append I use ios::app
Like if I have a file containing an employee's name and age, and I wanted to open the file and change the age, how do I do that??
Also, one webpage said ios::ate allows you to append ANYWHERE in the file, but it only allows me to append the end of the file. What am I doing wrong??
There is no "insert" mode for any kind of file operation. You can replace a fixed-length record in a file with another fixed-length record or you can append whatever you want to the end of a file.
If it's more complex than that, you basically have to create a new file with a mix of the old file you want to keep, and the changes you want to apply.