#include "Stdio.h"
#include "Conio.h"
typedef unsigned char BYTE;
BYTE fun (char* pr);
int main (void){
char* ptr = "1234567890ABCDEF";
BYTE arry[8];
int i;
BYTE *temp;
temp = arry;
while( *ptr != '\0'){
*temp = (fun( ptr) << 4) + fun( ptr + 1);
ptr = ptr + 2;
temp++;
}
for( i = 0; i < 8; i++)
printf("%x",arry[i]);
getch();
}
BYTE fun(char*pr)
{
BYTE temp;
/* if( *pr >= '0' && *pr <= '9'){
temp = *pr - '0';
}
if( *pr >= 'A' && *pr <= 'Z'){
temp = *pr - 'A' + 10;
} */
temp = ( *pr >= '0' && *pr <= '9' ? (*pr - '0') : (*pr - 'A' + 10) );
return temp;
}
阅读(989) | 评论(0) | 转发(0) |