atof
来源:互联网 发布:网络词强撩是什么意思 编辑:程序博客网 时间:2024/05/29 19:55
atof
1. 函数名: atof
功 能: 把字符串转换成浮点数
名字来源:ascii to floating point numbers 的缩写
用 法: double atof(const char *nptr);
程序例:
#include <stdlib.h>
#include <stdio.h>
int main()
{
float f;
char *str = "12345.67";
f = atof(str);
printf("string = %s float = %f\n", str, f);
return 0;
}
2. atof(将字串转换成浮点型数)
相关函数 atoi,atol,strtod,strtol,strtoul
表头文件 #include <stdlib.h>
定义函数 double atof(const char *nptr);
函数说明 atof()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果返回。参数nptr字符串可包含正负号、小数点或E(e)来表示指数部分,如123.456或123e-2。
返回值 返回转换后的浮点型数。
附加说明 atof()与使用strtod(nptr,(char**)NULL)结果相同。
范例 /* 将字符串a 与字符串b转换成数字后相加*/
#include<stdlib.h>
int main()
{
char *a="-100.23";
char *b="200e-2";
float c;
c=atof(a)+atof(b);
printf(“c=%.2f\n”,c);
return 0;
}
执行 c=-98.23
- 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 精度问题
- 使用简单批处理管理UI,铃声等用以区别客户的资源
- 开发常用工具--关键字
- POJ1125《Stockbroker Grapevine》方法:Floyd
- No4、在二元树中找出和为某一值的所有路径(树)
- WP8自定义控件之实现DataTemplate和绑定
- atof
- MapReduce 中如何处理HBase中的数据?如何读取HBase数据给Map?如何将结果存储到HBase中?
- TWAIN学习记录
- 隐藏控件的作用
- RAC环境下配置tnsname实现failover:TAF
- C程序设计(第二版 新版)第四章 习题
- 机器学习与人工智能学习资源导引
- Java笔记—String,StringBuffer ,StringBuilder 的区别
- ios push notification service _简单的服务器客服端解析以及代码。