It seems to be converting strings' characters to its numeric values. For instance, if you define "char c = '0';", you had indeed stored the ASCII code (or equivalent string encoding) of the char '0' in variable c, not the value zero itself. So to get the actual numeric value out of the ASCII code, you have to subtract by the ASCII code from the char '0'.
Remember that strings are a sequence of numeric values, i.e., integers representing characters, using the ASCII Table or equivalent, depending on the string encoding being used (Unicode, etc...).
Please note the actual characters' numeric values will depending on the actual encoding being used. The most known and basic Encoding is probably ASCII, which does not support languages other than the original english. For international purposes, the most common nowadays is UNICODE UTF-8, which uses basically the same codes used by ASCII for plain English usual characters, but other more complicated encodings exist.
And, as correctly noted by Anoop Rana in the other answer to this question, the C++ standard guarantees the numeric values will be in a sequence in any encoding. So, by using this technique, you avoid magic numbers that would make your code work just with specific encodings.
Here goes a didactic code that may help:
#include <iostream>
#include <string>
using namespace std;
int main()
{
const string str = "5";
cout << "char: " << str << endl;
cout << "ASCII char's value: " << (int)str[0] << endl;
cout << "ASCII char's value of the character '0' is: " << ((int)'0') << endl;
cout << "Value represented by the ASCII code " << str[0] <<
" is the binary value " << (int)str[0] << "-" << ((int)'0') <<
"=" << (str[0] - '0') << endl;
return 0;
}
The output is:
char: 5
ASCII char's value: 53
ASCII char's value of the character '0' is: 48
Value represented by the ASCII code 5 is the binary value 53-48=5
The ASCII table code can be consulted here:
https://www.asciitable.com/
By the way, I think there may be a bug in your code, since parameter b is not being used. Maybe the second 'if' should be taking the value of b instead of a?