The code runs without crashing, but when I look at the file afterwards in a hex editor, every byte (even those outside the range I thought I was writing to) are replaced with 00. I suspect I'm missing something in my understanding of file streams. Did I write that code correctly? Seekp does move the pointer over the next byte to be overwritten, yes? Am I getting a memory leak somewhere?
ios:ut erases an existing file. So if you open an existing file with that option, then seekp to a position, all bytes before that position are filled with 0x0.
It's not Philip Nicoletti's suggestion #4 that did the trick, it's #3 which opens an existing file for read/write access. IIRC, using this option on a non-existing file, then trying to write to it would fail. Watch out for the pitfalls of the filestream:pen options...
Last edited by Richard.J; January 3rd, 2013 at 05:22 PM.
Reason: sorry, could not find the option to disable those smilies