Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert a character into an integer of 16 in C language? (Converted to 10? )
How to convert a character into an integer of 16 in C language? (Converted to 10? )
Internationalorganizations (same as international organizations)

Interesting (character

*str)

{

Internationalorganizations (same as international organizations)

temp = 0;

while(*str)

{

temp * = 16;

if

(* str & lt= ' 9 ' & amp& amp* str & gt='0')

temp+= * str-' 0 ';

other

if

(* str & lt= ' f ' & amp& amp* str & gt='a ')

temp+= * str-' a '+ 10;

other

return

- 1;

str++;

}

return

Temperature;

}

I guess what you want is how to convert the decimal number of 16 into the decimal number of 10. The function above is.

If the parameters of the function do not meet the conversion requirements (there are abnormal characters), the function returns-1.

Here, I assume that you can write functions and know how to use them. . .