source: fact/tools/pyscripts/sandbox/dneise/fact_compress/c++/compare.cpp@ 14229

Last change on this file since 14229 was 14229, checked in by neise, 12 years ago
und so weiter
File size: 1.2 KB
Line 
1
2// reading a complete binary file
3#include <iostream>
4#include <fstream>
5using namespace std;
6
7ifstream::pos_type size;
8char * memblock;
9
10char c1,c2;
11
12int main () {
13
14 ifstream in1 ("a.fits", ios::in|ios::binary);
15 ifstream in2 ("bla.bin", ios::in|ios::binary);
16
17 if (in1.is_open() && in2.is_open())
18 {
19 long begin,end;
20 begin = in1.tellg();
21 in1.seekg (0, ios::end);
22 end = in1.tellg();
23 in1.seekg (0, ios::beg);
24 cout << "a.fits size:" << end-begin << endl;
25
26 begin = in2.tellg();
27 in2.seekg (0, ios::end);
28 end = in2.tellg();
29 in2.seekg (0, ios::beg);
30 cout << "bla.bin size:" << end-begin << endl;
31
32 while ( in1.good() && in2.good() )
33 {
34 c1 = in1.get();
35 c2 = in2.get();
36 if (c1 != c2)
37 {
38 cout << "difference found @ adress:" << hex << in1.tellg() << "\t" << in2.tellg() << endl;
39 cout << "in1:" << hex << int(c1) << endl;
40 cout << "in2:" << hex << int(c2) << endl;
41 }
42 }
43
44 in1.close();
45 in2.close();
46 } //end of if file open
47
48return 0;
49} //end of main
Note: See TracBrowser for help on using the repository browser.