fstream::write and '\n' and '\r'
Code:
fstream ifs(name, ios::out | ios::trunc | ios::binary);
unsigned __int8 word[2];
word[0]=(unsigned __int8)((unsigned __int16)width >> 8);
word[1]=(unsigned __int8)width;
if(!ifs.write((char *)word, 2))
throw new fileio_error("Cannot write width to file.");
Ignoring the other funkyness, this snippet should be writing {0x00, 0x0A} to the file, but is instead writing {0x00, 0x0D, 0x0A}. My immediate thought is that Windows is being retarded and adding carriage returns to all newlines written, which in this case is incorrect behavior, but I had thought that opening the file in binary mode would fix this problem. What do I need to do to have the snippet write exactly what I want, no questions asked, to the file?