|
|
1.1 root 1: /* Simple utility to compare 2 files.
2: * Diff or cmp are not sufficient, when
3: * comparing bioses :-)
4: *
5: * Copyright (c) 1998-2000 by Stefan Reinauer
6: */
7:
8:
9: #include <stdio.h>
10:
11: int main (int argc, char *argv[])
12: {
13: FILE *eins,*zwei;
14: int a,b,i=0,flag=0;
15:
16: if(argv[1]==NULL||argv[2]==NULL) {
17: printf ("Usage: %s file1 file2\n %s compares two files.\n",argv[0],argv[0]);
18: return 0;
19: }
20: eins=fopen(argv[1],"r");
21: zwei=fopen(argv[2],"r");
22:
23: if (eins==NULL) {
24: printf ("File %s not found or unreadable.\n",argv[1]);
25: return 0;
26: }
27: if (zwei==NULL) {
28: printf ("File %s not found or unreadable.\n",argv[2]);
29: fclose (eins);
30: return 0;
31: }
32:
33: while (!feof(eins)) {
34: a=fgetc(eins);
35: b=fgetc(zwei);
36: if (flag==0 && (a==-1||b==-1) && (a!=-1||b!=-1)) {
37: printf ("One file ended. Printing the rest of the other.\n");
38: flag=1;
39: }
40: if(a!=b) printf ("0x%06x: 0x%02x -> 0x%02x\n",i,a,b);
41: i++;
42: }
43:
44: fclose(eins);
45: fclose(zwei);
46: return 0;
47: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.