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