0, 1,2,3,4,5,6,7,8,9
* * * 10 characters.
When these ten characters are stored as characters, the values they store are the corresponding ascii codes, which are continuous and arranged according to their own numbers.
In this way, the character value can be converted into the corresponding value by subtracting the initial ascii code value.
set up
int a; //The target variable of the conversion.
Char c =' 7// The character to be converted.
c = a-' 0 ';
This is the corresponding value, that is, c = 7.
If you need to perform this operation multiple times in the file, you can define a macro with parameters as follows:
# Define charton number(x)(x-' 0')
So all you have to do is call.
C = chart number (a);
You can achieve the effect.