What exactly do you need help with? Open the file for read+write.
Position the stream at 500. Write the new byte. Close the stream.
Maybe he tried that and it didn't work.
There are several issues you have to pay attention to, at least
if you want to be portable:
-- First and foremost, the stream must be opened in binary
mode, and you must imbue the stream (or at least the
filebuf) with locale "C". Otherwise, a statement such as
"500th byte" doesn't really have any meaning.
-- The second thing is that if you really want to be strictly
portable, you have to use the two argument forms of seek,
e.g.: "myFile.seekp( 500, std::ios::beg )". In most
implementations, the one argument form will also work, but
according to the standard, there is in fact no guarantee
that an integral value will convert implicitly to a
streampos, and no guarantee that if it converts, the results
have any real relationship to the physical position in the
file.
And finally, as you say, you must open the file in read+write
mode (ios::in | ios:
ut), even if you're just writing; opening
in write only mode always truncates (unless you specify the
ios::app flag, but in that case, all writes are always to the
end of file, regardless of where you might be positionned
beforehand).