Say I have a file with some information in it and after my program runs I want to 'update' this information. Using seekp function I can set the position where the next character is to be inserted. But this overwrites the already existing information after the position I set to. How do I make it so that it adds information and doesn't overwrite.
Note that mode bits to open are combined with the bitwise or operator, not the logical or operator. Using the logical or operator will result in a value of true.
Thanks chervil.
Yeah i was thinking of something like that. But I'd have to load the whole file into memory and then modify it at places I want, I was just trying to find a more efficient solution.
Say i do something like this to load the file into memory
There are always choices, depending on what it is you want to do.
One way to read the file into a std::string (I'm sure there are other, better ways). This assumes that there is no ASCII zero character in the file.