Difference in using read/write when stream is opened with/without ios::binary mode
问题 In my experiments with the following code snippet, I did not find any particular difference whether i created the streams with/without the ios:binary mode: int main() { ifstream ostr("Main.cpp", ios::in | ios::binary | ios::ate); if (ostr.is_open()) { int size = ostr.tellg(); char * memBlock = new char[size + 1]; ostr.seekg(0, ios::beg); ostr.read(memBlock, size); memBlock[size] = '\0'; ofstream file("trip.cpp", ios::out | ios::binary); file.write(memBlock, size); ostr.close(); } } Here I am