// reading a complete binary file #include #include using namespace std; ifstream::pos_type size; char * memblock; char c1,c2; int main () { ifstream in1 ("a.fits", ios::in|ios::binary); ifstream in2 ("bla.bin", ios::in|ios::binary); if (in1.is_open() && in2.is_open()) { long begin,end; begin = in1.tellg(); in1.seekg (0, ios::end); end = in1.tellg(); in1.seekg (0, ios::beg); cout << "a.fits size:" << end-begin << endl; begin = in2.tellg(); in2.seekg (0, ios::end); end = in2.tellg(); in2.seekg (0, ios::beg); cout << "bla.bin size:" << end-begin << endl; while ( in1.good() && in2.good() ) { c1 = in1.get(); c2 = in2.get(); if (c1 != c2) { cout << "difference found @ adress:" << hex << in1.tellg() << "\t" << in2.tellg() << endl; cout << "in1:" << hex << int(c1) << endl; cout << "in2:" << hex << int(c2) << endl; } } in1.close(); in2.close(); } //end of if file open return 0; } //end of main