I was able to read and write without setting any binary flag:
#include <fstream>
#include <iostream>
struct C {
C(int X = 0, int Y = 0) :x(X), y(Y) {}
int x; int y;
};
int main()
{
C Point1(4, 9);
C Point2;
std::fstream IOFile("Test.txt",
std::ios_base::in | std::ios_base::out);
IOFile.write((char const*)&Point1, sizeof(C));
IOFile.seekg(std::ios_base::beg);
IOFile.read((char*)&Point2, sizeof(C));
IOFile.close();
}
The write and read functions returned the same data regardless of whether binary flag was set or not. So, where is this flag really necessary?