what dose that mean

what dose this 3 sentence mean in c++
int j=static_cast<int>(x[i])-48;
int k=static_cast<int>(x[i-1])-48;
int l=static_cast<int>(x[i-2])-48;

first line: It is casting x[i] to an integer and then subtracting 48.

rest are similar.

Without knowing how x is declared, I'm guess it is an array of characters or a char*
and is an ASCII integer, eg, "123".

Subtracting 48 is a way of converting the character '1' to the integer 1 because
the ASCII value of '0' is 48.
Topic archived. No new replies allowed.