经常面试到的题目:atoi 函数(将字符串转换成整型数)
int atoi(const char *s)
{
if(*s==null)
return;
char *p = s;char c;
int i = 0;
while(c=*p++)
{
if(c>='0' && c<='9')
{
i = i*10 + (c-'0');
}
else
return -1; //Invalid string
}
return i;
}
经常面试到的题目:atoi 函数(将字符串转换成整型数)
int atoi(const char *s)
{
if(*s==null)
return;
char *p = s;