   Binary output ofstream/VC++ WTF?!?!
  char c[4] = {2,0x0A,0xFF,0x0D};ofstream o;o.open("test");o.write(c, 4);o.close();//first five bytes of test:02, 0D, 0A, FF, 0Dofstream inserts 0x0D before 0x0A! I tried a few other cases too. This is banal! I figure it''s because 0A is Line-Feed, and 0D is carriage return, and for some reason M$ expects that I''m trying to create a file for reading.anyone know of a workaround? or maybe a flag I''m not setting right?   George D. FiliotisI am a signature virus. Please add me to your signature so that I may multiply.
  You need to open your ofstream with the ios::binary flag. ;  o.setmode(filebuf::binary); ;  ofstream o("test.txt", ios::binary); ;quote:Original post by Programmer16  ofstream o("test.txt", ios::binary);   Do you have to give the other flags with it? Like ios::out and ios::trunc? Or are they assumed by the ofstream class? ;  With ofstream, ios::out is assumed. And with ifstream, ios::in is assumed. If you want to use ios::trunc you do have to apply it too.Example:ofstream o("test.txt", ios::binary | ios::trunc);   /*I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)*/ 