Doubt on String to Integer Conversion

I am not able to do this coversion. I surfed stackoverflow and got this link, but idk how that formula came.
please explain me

here is the link
and formula is value += (str[0] - ‘0’)*pow(10,count);

If you have a better and easy solution, let me know. Thanks

there are three ways-

  1. using in built lexica_cast() function
  2. using in built string streams
  3. String conversion using stoi() or atoi() functions
    choose any one , these in built functions are the best