I had this issue a while ago, but I'm working on something new and I don't want to run into the same thing. Here's the problem. I was using fopen(filename, "wb") to overwrite a file that already exists, somtimes with a smaller amount of data (hence, smaller file), and it left garbage on the end of the file. Say the existing file was 100 bytes and I only wrote 10. It overwrote the first 10 bytes and the other 90 bytes were still there. So it seems it didn't really kill the existing file like I wanted. Any ideas? Am I missing something with the "wb" in fopen()?
"w" Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.