写的不好,也不知道是否符合c语言的规范,按c++到是可以编译,看着用吧。。:
#include "math.h"
int StrToNum(const char * pstr)
{
int iresult = 0;
const char * pstrRun = pstr;
while (pstrRun[0] != '\0')
{
if (pstrRun[0] > 1 && pstrRun[0] <255 && isdigit(pstrRun[0]))
{
iresult *= 10;
iresult += (pstrRun[0] - '0');
}
++pstrRun;
}
return iresult;
}本回答被提问者采纳