📄 ex7_7.c
字号:
/*
ex_7_7
To change the string to the float_number.
*/
float atofloat(string)
char string[];
{
char temp ;
float result = 0 , point = 0 ;
int index = 0 , sign = 1 ;
if ( string[0] == '-' )
{
index = 1 ;
sign = -1 ;
}
while ( (temp = string[ index++ ]) != '\0' )
{
if (temp == '.')
point = 10 ;
else if (point)
{
result += (temp-'0')/point ;
point *= 10 ;
}
else
{
result = result*10 + temp-'0' ;
}
}
return ( sign*result ) ;
}
main ( )
{
char string[10];
float value ;
printf("Number :\n");
scanf ("%s",string);
value = atofloat(string);
printf("\n%f\n",value);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -