// reading a complete binary file #include #include #include #include using namespace std; ifstream::pos_type size; char * memblock; char c1,c2; int main (int argc, char * argv[]) { ifstream in1 ( argv[1], ios::in|ios::binary); ifstream in2 ( argv[2], 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 << argv[1] <<" size:" << end-begin << endl; begin = in2.tellg(); in2.seekg (0, ios::end); end = in2.tellg(); in2.seekg (0, ios::beg); cout << argv[2] <<" 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; printf ("%30s \t: 0x%X \n", argv[1] ,uint8_t(c1) ); printf ("%30s \t: 0x%X \n", argv[2] ,uint8_t(c2) ); break; } } in1.close(); in2.close(); } //end of if file open return 0; } //end of main