strtod - 将字符串转换为双精度时出现问题
我有一个非常小的程序,它将字符串转换为双精度。问题是每次打印 0.0000 时。 请帮我。
提前致谢。
enter code here
$ export LT_LEAK_START=1.5
$ echo $LT_LEAK_START
1.5
#include <stdio.h>
int main()
{
double d;
d=strtod(getenv("LT_LEAK_START"), NULL);
printf("d = %lf\n",d);
}
Output:
d=0.0000000
I have a very small program which converts a string to double. The problem is everytime it is printing 0.0000.
Please help me.
Thanks in advance.
enter code here
$ export LT_LEAK_START=1.5
$ echo $LT_LEAK_START
1.5
#include <stdio.h>
int main()
{
double d;
d=strtod(getenv("LT_LEAK_START"), NULL);
printf("d = %lf\n",d);
}
Output:
d=0.0000000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试包括
Try including
您不包括 strtod decl 标头(stdlib.h),因此您使用内部 strtod 实现(这似乎只是一个存根?)
忽略 sigsegv,在我的平台上是由 getenv() 引起的,它也被声明在 stdlib 中,但没有内部 gcc impl
you aren't including the strtod decl header (stdlib.h) so you are using an internal strtod implementation (which seems to be just a stub?)
ignore the sigsegv, on my platform is caused by getenv() which is declared as well in stdlib but has no internal gcc impl