if(ch & gt; = ' 0 ' & amp& ampch & lt= '9')
{
n = ch-' 0 ';
}
If it is a string to an integer, you can use the function atoi ()
char SZ number[32]= " 1234 ";
int n = atoi(SZ number);