I tried this method to convert a char digit to an integer digit ('3'->3) and it seems to work.
char c='x';
int i=atoi(&c);
My question is, will this always work?
Is there always a NULL character after the first character?
There is another way to do this using implicit typecast, but I am not sure it is a good practice. Actually, I am pretty surprised there are no warnings even using -Wall and -Wextra.
int i = c - '0';
Note I am using GCC 4.8.2 and MinGW.