This should be to convert characters into integers, and the mathematical operation between characters refers to the operation between ascll codes. S is an integer variable.
The final result of p[i][j]-'0' is their difference. For example, if p[i][j]=25, then S = 25p[i][j]=A, s=65-48= 17.