51 is the numeric value for the letter character '3'. It goes back to the ASCII standard, although many common Unicode encodings also support value.
You can pretty safely just subtract 48 (or '0') to get the number:
int num = (int)(numAsChar - '0');
Alternatively, if you want to convert the whole string, you can use atoi :
int num = atoi(myNumberString);
source share