Can't we use typecasting instead

can’t we use typecasting instead of writing :
int digit = in[i]-‘0’;
in video cpp-recursion-phone Keypad

Hi
In this context, No, because ASCII value of 5 is 53, if you typecast to int it will give you 53. here we want 5 only. So that is why we subtract ‘0’ which has ASCII code 48
53-48=5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.