입력 : 16진수값(0~9, A~F)를 10진수의 값으로 바꾸기
int hextodec( char *str )
{
int nInt = 0;
int nSeed = 0;
char cChar;
int i;
for( i = 0; str[ i ]; i++ )
{
nInt = nInt << 4;
switch( str[ i ] )
{
case 'F':
case 'f':
nSeed = 15;
break;
case 'E':
case 'e':
nSeed = 14;
break;
case 'D':
case 'd':
nSeed = 13;
break;
case 'C':
case 'c':
nSeed = 12;
break;
case 'B':
case 'b':
nSeed = 11;
break;
case 'A':
case 'a':
nSeed = 10;
break;
default:
cChar = str[ i ];
nSeed = atoi( &cChar );
break;
}
nInt += nSeed;
}
return nInt;
}