标签:io ar sp on 数据 bs ef size nbsp
#include<stdio.h>
#include<ctype.h>
#define SIZE 1000
double my_atof(char const *str)
{
float ret = 0;
float temp = 0;
int sign = 0;
while(isspace(*str))
str++;
if(*str == ‘-‘)
{
sign = -1;
str++;
}
else
{
sign = 1;
}
while(isdigit(*str))
{
ret = ret * 10 +(*str-‘0‘);
str++;
}
while(*str != ‘\0‘)
{
NULL;
str++;
}
while(isdigit(*(--str)))
{
temp = temp / 10 +(*str-‘0‘);
}
temp = temp / 10;
return sign * (ret + temp);
}
int main()
{
float number;
char *string = "35.00001";
number = my_atof(string);
printf("%f\n",number);
return 0;
}
标签:io ar sp on 数据 bs ef size nbsp
原文地址:http://www.cnblogs.com/waiting-for/p/4135032.html