Elektrine lite

← Feed

@schelling@mastodon.gamedev.place

2026-05-09 18:55 UTC

I learned today that in C when opening a file for updating (i.e. fopen with mode "rb+") one needs to call fseek first when switching between reading and writing to force reset internal buffers. Even just seeking to a 0 offset from the current position works. Otherwise things can randomly break depending on the platform, the size of the existing file, or the amount of data being read/written. Baffling that a debug build wouldn't warn about this.

Replies (0)

No replies.