Binary mode

Hi, I want to open a binary file for reading and writing (without truncation, not for adding). I use the "r + b" mode. I do not get compilation of errors, but when I read what I wrote, I get garbage values. Any idea.

But if I open the file for writing (mode like "wb"), write it to ... close it, and then open the file for reading (mode "rb") and read it, then it works fine,

0
source share
2 answers

When you open a file in read / write modes such as "r +", "w +", you need to make sure that the file pointer points to the actual position. fseek () is your friend here.

, , . , , fread() , .

+2

- , , , , .

0

All Articles