如何将字符串转换为浮动? [英] How to convert string to float?
本文介绍了如何将字符串转换为浮动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<stdio.h>
#include<string.h>
int main()
{
char s[100] ="4.0800" ;
printf("float value : %4.8f\n" ,(float) atoll(s));
return 0;
}
我期望输出应该是:4.08000000
在这里我只拿到了4.00000000
I expect the output should be : 4.08000000 where as I got only 4.00000000
有什么办法点后得到的数字
Is there any way to get the numbers after the dot
推荐答案
感谢所有回答
我发现ATOF()工作,但我们应该包括文件stdlib.h
与ATOF一起()来获得
正确的答案
I found that the atof() is working , but we should include the stdlib.h
along with atof() to get the
right answer
我不知道这是什么头文件确实在这个但这项纳入我们不能
获得所需的值
I dont know what this header file does in this but with out this inclusion we cannot get the desired value
这篇关于如何将字符串转换为浮动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文