The >>
and <<
operators are designed for formatted operations, while you need binary operations. Try opening the stream with ios::binary
:
ifstream in( filePath.c_str(), ios::binary );
and using read
(or readsome
) and write
to handle I/O.
If you want to stick with formatted operations (which you shouldn't if you`re into encryption), use getline
to read lines containing whitespace characters;