Showing posts with label file I/O. Show all posts
Showing posts with label file I/O. Show all posts

Saturday, 4 May 2013

Binary file read by std::ifstream is corrupted

By default, std::ifstream is constructed with text mode. On windows, it will convert new line character which may corrupt the binary file.

The fix is to use std::ifstream::binary as the second parameter when construct ifstream for binary file.