Does any one know of a atolf c function?

2019-07-30 14: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.

2条回答
女痞
2楼-- · 2019-07-30 15:02

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

查看更多
Deceive 欺骗
3楼-- · 2019-07-30 15:08

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.

查看更多
登录 后发表回答