Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert the character 1 into an integer 1
How to convert the character 1 into an integer 1
C How to convert the character 1 into an integer1;

The first type: subtract' 0' from digital words, that is,' 1'-'0' (subtract with ASCII code, that is, 49-48= 1).

The second type: digital word minus 48(48 is the ASCII code of' 0'), that is,' 1'-48= 1.

For example, I want to change' 2' to 2.

int k;

char b='2 '

K=b-48 or k=b-'0'

C:

C language is a general computer programming language, which is widely used. The design goal of C language is to provide a programming language that can compile and process low-level memory in a simple way, generate a small amount of machine code and run without any support of running environment.