From what I've tested, if I do that, the rest of the file is gone. Do I need to read it entirely to a string/vector, change just the bytes I need in the string/vector, then write all the file again?
From what I've tested, if I do that, the rest of the file is gone. Do I need to read it entirely to a string/vector, change just the bytes I need in the string/vector, then write all the file again?
No, that's not necessary. The rest of the file should remain completely unaffected.
You also need to specify ios::in. If you're opening it in write-only mode, it will truncate the file to 0 bytes when it is opened.
Also, if you want to write all three ints, you need to write melda.size()*sizeof(int) characters.