whyy, str[newIndex] - ‘0’ is not done to calculate the ascii value
Calculation of the ascii value
str[newIndex] - ‘0’ will not give the ascii value. It will basically give the difference between the numIndex character and ‘0’, that is, how many characters lie in between them. For example, to find the ascii value of z, doing ‘z’ - ‘a’ will give 25. However doing (‘z’ - ‘a’) + 65 will give the actual Ascii value.
In short you will have to do (str[newIndex] - ‘0’) + 48 to find the true ascii value of str[numIndex]