How do I convert a char to an int in C and C++?
char
int
Use static_cast:
static_cast
int num = static_cast(letter); // if letter='a', num=97
Edit: You probably should try to avoid to use (int)
(int)
int num = (int) letter;
check out Why use static_cast(x) instead of (int)x? for more info.