I'm trying to write some value to a file byte by byte while when it comes to the value of 10, it write 0D0A instead of only 0A ot the file, any idea?
unsigned char m = 10;
ofstream fout("1.file");
fout << m;
fout.close();
I'm trying to write some value to a file byte by byte while when it comes to the value of 10, it write 0D0A instead of only 0A ot the file, any idea?
unsigned char m = 10;
ofstream fout("1.file");
fout << m;
fout.close();
I'm guessing you're on a Windows system, where newlines ('\n'
, ASCII value 10
) are automatically translated to the Windows newline "\r\n"
(ASCII values 13
and 10
).
This translation happens for all files opened in text mode on Windows. And in the opposite direction when reading. Opening in binary mode will not do this translation.