#include
#include
#define COLS 0x10
#define PAUSE 10
int main(int argc,char** argv){
guint i = 0;
guint col = COLS;
FILE* fa = NULL,*fb = NULL;
guint count = 0;
guint len_a =0,len_b = 0;
char buf_a[COLS],buf_b[COLS];
guint pause = 0;
if(argc < 3){
g_print("Usage:010.app file1 file2\n");
return -1;
}
fa = fopen(argv[1],"rb");
if(fa == NULL){
g_print("error when open %s\n",argv[1]);
return -1;
}
fb = fopen(argv[2],"rb");
if(fb == NULL){
g_print("error when open %s\n",argv[2]);
return -1;
}
while((len_a = fread(buf_a,1,col,fa)) == col && (len_b = fread(buf_b,1,col,fb)) == col){
int size = 0;
if(count % col == 0){
g_print("%08d:\n",count);
}
size = MIN(len_a,len_b);
count += size;
g_print("A:");
for(i = 0; i < size;i++){
g_print("%02x ",(guchar)buf_a[i]);
}
g_print("\n");
g_print("B:");
for(i = 0; i < size;i++){
g_print("%02x ",(guchar)buf_b[i]);
}
g_print("\n");
if(pause++ == PAUSE){
g_print("Press Enter to continue,(q|Q) to quit\n");
char c = fgetc(stdin);
if(c == 'q' || c == 'Q') break;
pause = 0;
}
}
fclose(fa);
fclose(fb);
return 0;
}