The value of '5' as a number is 5. The value of '7' as a number is 7. The value of '0' as a number is 0.

So, subtracting '0' from a character representing a digit results in the digit that the character represents.

Actually, each of these characters has two values: the one that we want, and the one that is used internally by the software.

As far as the software is concerned:

the value of the character '0' is the number 48;

the value of the character '1' is the number 49;

the value of the character '2' is the number 50; and so forth.

But (as I'm sure you know) those aren't the values we want!

So we subtract 48 from each of these values to get the values we want.

The value of the character '0' is the number 48, but we want the number 0, so we subtract 48 from 48 to get 0.

The value of the character '1' is the number 49, but we want the number 1, so we subtract 48 from 49 to get 1.

The value of the character '2' is the number 50, but we want the number 2, so we subtract 48 from 50 to get 2.

And so forth.

For more characters, please see this link:

https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html