Does any one know of a atolf c function?

北慕城南 提交于 2019-12-11 06:56:50

问题


I am looking for a function similar to atol (char * to long int) but atofl (char to long double), does anyone know of a library that does this, or a simple way to do this, since using atof on "0.00000005" casts off the 5? Thanks.


回答1:


There is a function called strtod that does what you want.




回答2:


I think you have use the wrong argument of printf, so you only saw the console giving you "0.000000", you can try

printf("%0.10f", atof(str_num));

to show the your number, and you will find what you want.



来源:https://stackoverflow.com/questions/10992052/does-any-one-know-of-a-atolf-c-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!