In poche parole atoi dovrebbe are questo?

int i = 0;

int foo (char *st)
{
while (*st != '\0')
{
*st = *st - '0';
i++;
}

i --;

int app, j, m = 1;
for (j = i; j > 0; j++)
{
app += st[i];
m*=10;
}
return m;
}

sbaglio?