#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
FILE *fdb = NULL;
FILE *fda = NULL;
unsigned char c;
char h[2];
if (argc!=2)
return -1;
if (NULL == argv[1])
return -1;
fdb = fopen(argv[1], "rb");
if(NULL == fdb)
return -1;
fda = fopen("asc.txt", "wb");
if (NULL == fda) {
fclose(fdb);
return -1;
}
while(fread(&c, 1, 1, fdb) != 0) {
//printf("%d", c);
sprintf(h, "%2x", c);
if (h[0] == ' ')
h[0] = '0';
fprintf(fda, "%c", h[0]);
fprintf(fda, "%c", h[1]);
//printf(" = %c%c/n", h[0], h[1]);
}
fclose(fda);
fclose(fdb);
return 0;
}