Skip to main content
GameDev.net gamedev.net
🔒 Locked

FILE*s and changing 4 bytes

Started by MadProgrammer Dec 7, 2001 at 11:08 AM 1 replies 300+ views
Original Post
MadProgrammer
MadProgrammer
i want to change 4 bytes of a file, starting at the 6th byte, leaving the rest of the file intact. here''s what i tried to do: FILE *f; f = fopen(filename, "w+b"); fseek(f, 6, SEEK_SET); unsigned int v = 1; fwrite(&v, sizeof(v), 1, f); fclose(f); problem: that erases the rest of the file. how do i do it w/o erasing the rest of the file?
MadProgrammer
MadProgrammer
yup, that worked.

i thought about trying that, but assumed that it would throw some sort of error. apparently not!

thanks

Topic Locked

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

Sign in to reply to this topic.