A program with a function that converts a string of digits into an integer value Here is a programming task:

Write a program with a function that converts a string of digits into an integer value. Do not use the strtol() function or any other standard C library function. Write your own!

I wanted this program to work perfectly with no errors. First I did the power function (power) and then next is function that return the length of a string (lent) and lastly is function that gives the value of asciicode (ascton).
In the main function there is a loop for the string where it multiple the value of how much zeros in has after it. For example, the string is &quot;1100&quot; so the first 1 is 1000 then this value is stored in variable z, and then this works for the other character and add it to variable z. At the end it return z as an integer of the string.
Is this code efficient, or did I use the &quot;long way&quot;? Please give me some hints how I can write better, cleaner and more readable code. Any feedback is appreciated.
#include &lt;stdio.h&gt;
#include &lt;math.h&gt;



int powe(int ex , int po)
{
  int z = 1;
  for (int i = 0; i &lt; po; i++)
  {
    z = z * (10 * 1);
  }
  return z;
}


int lent (char a [20])
{
  int i=0;
  int l = 0;
  for(i=0 ; a[i] != '\0';i++)
  {
    l++;

  }
  return l;
}


int ascton (int a)
{
  int asciicode[10] = {48,49,50,51,52,53,54,55,56,57};
  for(int i = 0; i &lt; 10; i++)
  {
    if (a == asciicode[i]) 
    {a = i; 
     break;}
    else continue;
  }
  return a;
}


int main(void) {
  
  int z = 0;
  char sn[20];
  printf(&quot;enter your string number!:&quot;);
  scanf(&quot;%s&quot;,sn);
  
  
  int s = lent(sn);
  
  
  for(int i = 0; sn[i] != '\0';i++)
  {
    int k = 0;
    k = ascton(sn[i]);
    z = z + (k * powe(10, s-1));
    s = s-1;
     
  }
 printf(&quot;%d&quot;,z);
}
```
is this code efficient ?

No.  Rather than using the unnecessary powe(), lent(),

simply scale by 10 each operation; and
use - '0'.

.
char sn[20];
//scanf(&quot;%s&quot;,sn);
if (scanf(&quot;%19s&quot;, sn) == 1) {
  int z = 0;
  for (int i = 0; sn[i] &gt;= '0' &amp;&amp; sn[i] &lt;= '9'; i++) {
    z = z*10 + (sn[i] - '0');
  }
  printf(&quot;%d&quot;,z);
}

Even better code would detect overflow and maybe use unsigned and/or wider types.