Skip to main content
gamedev.net
🔒 Locked

file input/output

Started by djsteffey 1 reply 200+ views
Original Post
djsteffey
djsteffey
can i open an output file stream (in binary) and just change individual bytes in the file for eaxmple: say i want to open a file in binary, but i only want to modify the first 2 bytes of the file then save the file with the first two bytes changed. Can i do this or would i have to read in the entire file, change first two bytes and then save entire file ? "Now go away or I shall taunt you a second time" - Monty Python and the Holy Grail themGames Productions
Anti-dentite
Anti-dentite
you can use fseek to seek to the part of the binary file you want to read and then fwrite over it, or fread to read it into memory (of course, this is in borland c)
SiCrane
SiCrane
Depending on OS, it''s also possible to just map the file to memory and then twiddle the bits. Of course in Windows File mapping is suppose to be just used for IPC, but it may be more convienient to use it for just file editing.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.