I am using VS 2005.
In a project when I was trying to write some unsigned char into a file, I used fwrite() and fputc(). But I found whenever I tried to write 0x0a, fwrite() function automaticly wrote 0x0d before 0x0a. So I wrote a small test to test it. Here is it:
FILE* file;
unsigned char p = 0x0a;
long offset = ftell(file); // here the offset = 0;
fwrite(*p,1,1,file);
offset = ftell(file); // after this, the offset = 2. and in the file I
// found 0x0d and 0x0a was written.
I can't understand. I just want to write byte by byte, automatically inserted byte 0x0d will cause problems in my project.
can someone tell me what is the cause and how to avoid the unwanted byte
Visual C++9
|