I\'m outputing an array of unsigned characters in C++ using ofstream fout(\"filename\");
but it produces a spurious character in between. This is the part of th
Your stream is opening in text mode, and since 0x0A
is the line feed (LF) character, that's being converted by your stream to 0x0D
0x0A
, i.e. CR/LF.
Open your stream in binary mode:
std::ofstream fout("filename", std::ios_base::out | std::ios_base::binary);
Then line ending conversions should not be performed.
This is usually considered a good idea anyway, as streams can go bizarre w.r.t. flushing when in text mode.