bob@coolgroups. com wrote:[color=blue]
> Is there a way to overwrite a random byte in a file using FILE without
> rewriting the whole file?[/color]
Yes. Open the file for reading/writing, then use fseek to get to the
position where you want to write, then use fwrite, then close it. IIRC
on some platforms you could end up with a truncated file unless you
open it for both reading and writing, you will need to check with your
documentation.
Tribal-Tec wrote in message
<1134216580.335 287.171610@g44g 2000cwa.googleg roups.com>...[color=blue]
>The modern cpp way would be the use of fstream;
>std::ofstrea m myFile; // or fstream for both writing and reading
>myFile.open( "filename", std::ios_base:: binary | std::ios_base:: out );
>
>now with seekg method you can place the write cursor to modify your
>desired byte.[/color]
The 'g' in 'seekg' means 'get' to me. Use 'seekp' to 'put'.
"Kern" <kernel1983@gma il.com> wrote in message
news:1134189993 .468429.27470@o 13g2000cwo.goog legroups.com...[color=blue]
> But it's quite classic way to moditfy the binary file.
> How can we do this in a modern cpp way?
>[/color]
Surely you could use streams but what will you gain in this case?
Comment