String to integer recursion

in the video sir gave input as 1234 and we had to convert this string into integer so the output should be 1234 but we are getting 1235 which is wrong because instead of 5 it should be 4

int digit =a[n-1]-‘0’ isme char array mai jo digit ha usko hum “0” character se subtract kar rahe hai toh vo intger mai store kyu ho raha hai?

Whenever you apply arithmetic operations on character, it is done in the form of their ascii value.
Ascii value of digits 0-9 is from 48-57.
So subtracting it by ‘0’ actually gives you the digit in integer form.
Ascii value of ‘2’ is 50. And ascii value of ‘0’ is 48.
So ‘2’-‘0’ = 50-48 =2