1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <stdlib.h> #include <ctype.h> #define MAXN 16 char buf[MAXN];
int () { FILE* fp = fopen("Microsoft.pub","rb"); if(fp == NULL) { perror("error"); return 0; } int cnt = 0; int offset = 0; while((cnt = fread(buf, sizeof(char), MAXN, fp)) != 0) { printf("%08xt",offset); for(int i = 0; i < cnt; ++i) printf("%02hhx ",buf[i]); putchar(' '); for(int i = 0; i < MAXN-cnt; ++i) printf(" "); for(int i = 0; i < cnt; ++i) { if(isprint(buf[i])) putchar(buf[i]); else putchar('.'); } puts(""); offset += cnt; } return 0; }
|
近期评论