atof
来源:互联网 发布:淘宝暗语大全 女 编辑:程序博客网 时间:2024/05/16 10:13
double atof ( const char * str );
double atof ( const char * str );
Convert string to double
Parses the C string str interpreting its content as a floating point number and returns its value as a double.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals, and interprets them as a numerical value. The rest of the string after the last valid character is ignored and has no effect on the behavior of this function.
A valid floating point number for atof is formed by a succession of:
- An optional plus or minus sign
- A sequence of digits, optionally containing a decimal-point character
- An optional exponent part, which itself consists on an 'e' or 'E' character followed by an optional sign and a sequence of digits.
Parameters
- str
- C string beginning with the representation of a floating-point number.
Return Value
On success, the function returns the converted floating point number as a double value.If no valid conversion could be performed, or if the correct value would cause underflow, a zero value (0.0) is returned.
If the correct value is out of the range of representable values, a positive or negative HUGE_VAL is returned.
Example
/* atof example: sine calculator */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (){
double n,m;
double pi=3.1415926535;
char szInput [256];
printf ( "Enter degrees: " );
gets ( szInput );
n = atof ( szInput );
m = sin (n*pi/180);
printf ( "The sine of %f degrees is %f\n" , n, m );
return 0;
}
Output:
Enter degrees: 45
The sine of 45.000000 degrees is 0.707101
- atof()
- atof
- atof
- atof
- atof函数
- atof&strtod
- atof(), sscanf()的区别
- atoi,atol,strtod,atof
- atoi atof源码
- atoi,atol,strtod,atof
- atoi,atof实现
- atof简单实现
- atof 函数参考
- atof c语言实现
- atoi atof源码
- atof简单实现
- atof简单实现
- atof 精度问题
- shell脚本学习:正则表达式之sed,tr篇
- 记本无法连接MINI2440 ARM开发板串口总结 .
- eclipse快捷键
- POJ2516 Minimum Cost 最小费用最大流
- C++代码转化为Java注意点(一)赋值
- atof
- ajax静态刷新页面方法
- new/delete malloc free
- poj 1321
- 1359 括号匹配
- 遇到的Linux反汇编问题 & 转载一篇好文章
- win7 vmware 安装 mac 10.6 snow leopard 参考和经验
- 高考被不喜欢的专业录取该怎么办?
- 设置 Oracle 监听器密码(LISTENER)