linux 下,atof()转换字符串之后打印不出来

linux 下,atof()转换字符串之后打印不出来,第1张

我在FreeBSD里面用 man atof 查看说 atof 函数是 not thread-safe and also not async-cancel-sfae

deprecated by strtod,建议你用strtod 试试。alt = strtod((_alt.c_str()), NULL)

像oowood仁兄提的,你可以在106行先输出一个_alt.c_str()看看是什么内容。

很好写啊~

char c[] = "12.34"

double d

sscanf(c,"%lf",&d)

sscanf的作用是从给定字符串中按照某格式读数

---

在我的编译器上你的程序没有问题

你按照我写的试试吧

#include <stdio.h>

int main(){

char str[] = "12.34"

double d

sscanf(str,"%lf",&d)

printf("%lf",d)

return 0

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7152129.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-02
下一篇 2023-04-02

发表评论

登录后才能评论

评论列表(0条)

保存