Open the file in binary mode instead of text mode. If you use fopen , open it in one of the "b" modes, for example. "rb" . If you are using a C ++ ifstream , open it using the ios::binary flag.
For instance:
// C method FILE *f = fopen("filename", "rb"); // C++ method std::ifstream f("filename", std::ios::in | std::ios::binary);
source share