Convert to int function

i didn’t understand the convertToInt function in the program

int convert_to_int(string s)
{
    int a=0,p=1;
    for(int i=s.length()-1;i>=0;i--)
    {
        a+=((s[i]-'0')*p);
        p=p*10;
    }
    return a;
}

Are you taking about this function??
this is simple function
suppose s = “1234”
then we are each character of string from end
first we have s[3] which is ‘4’ (a character)
to convert character 4 to int we have subtracted it with ‘0’
s[3]-‘0’ will give us integer 4
and similary we have done with other
and join them according to their place values