Supplement to the question: it is the law of subtracting 48 instead of 54. When the character' 6' is converted into plastic 6, 48 must be subtracted, because the ascii code corresponding to the character' 6' is 54, that is,' 6'-48 = 6.
In the function hextoint, through itoa(hexvalue, tem,16); There are two characters in the converted tmp, "6" and "8". At this time, according to the ascii table, the value of tem[0] is 54, so you must subtract 48 from the character' 6' to get the number 6.
# include & ltstdio.h & gt
# include & ltstring.h & gt
IntHexpoint (unsigned long hexadecimal value)
char tem[3]= { 0 };
int dec value = 0;
itoa(hexvalue,tem, 16);
dec value+= 16 *(tem[0]-48);
dec value+= tem[ 1]-48;
Return decvalue
}
void main(){
Printf ("value: [%d]\n",
hextoint(0x68)
);
};
Of course, the easiest way is
void main(){
printf("values:[%d]\n ",0x 68);
};
This is a joke.