#include <cstdio>
#include <cassert>
int atoi(const char* str)
{
assert(str!=NULL);
const char* s = str;
int value=0;
while(*s!='\0')
{
value *= 10;
value += *s - '0';
s++;
}
return value;
}
int main()
{
printf("%d\n",atoi("1234"));
}
转载于:https://www.cnblogs.com/hxf829/archive/2009/10/09/1659755.html