您的位置:首页 > 其它

atof 把字符串转换成浮点数

2012-06-22 09:37 176 查看
名字来源:array to floating point numbers 的缩写

用 法: double atof(const char *nptr);

#include <iostream>
#include <stdlib.h>
#include <string>
int main()
{
//std::string ss("478");
char *str = "123";
double f_ss;
f_ss = atof(str);
std::cout<<f_ss/2<<std::endl;
return 0;
}

运行结果:61.5
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐