I am writing a program to generate a bitmap image. When I was testing it, I found that C++ was writing extra bytes (at seemingly random locations) thus offsetting all of my bytes (subsequently messing up the image). I write to the file from an array. I cout the complete contents of the array, and they are perfect, however the extra bytes are always written. This was fixed by opening the file with the ios::binary flag.
Why would opening the file with and without the ios::binary flag matter if I am outputting from the exact same array.
Using Code::Blocks 12.11, default compiler with C++0X