static char* p;
if(str)
p = str;
double num = 0;
while(*p && !(*p>='0'&&*p<= '9'))
++p;
if(*p == 0)
return -1;
while(*p>='0' && *p<='9') {
num = num*10+*p-'0';
++p;
}
if(*p == '.') {
++p;
double i = 10;
while(*p>='0' && *p<='9') {
num += (*p-'0')/i;
++p;
i *= 10;
}
}
return num;
轉載From:https://www.cnblogs.com/VincentValentine/p/5677353.html
貼在這裏,作爲自己日後回顧學習使用,如有冒犯,本人可立即刪除!