Don't use the formatted stream insertion (<<) or extraction (>>) operators with binary files.
Instead, use the istream::read
or ostream::write
methods.
Edit 1: Example of block reading.
#define BUFFER_CAPACITY 512
unsigned char buffer[BUFFER_CAPACITY];
ifstream input_data("my_data.caf");
input_data.read((unsigned char)&buffer[0], sizeof(buffer));
//...
cout << "Look, first by is "
<< "0x" << hex << buffer[0]
<< " or as decimal: " << dec << buffer[0]
<< endl;