在C++中如何将文本中的文本转换为数字???

blackwind 2001-12-31 11:01:46
比如将"120.4"转换为数字120.4
...全文
165 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
comstar 2002-01-01
  • 打赏
  • 举报
回复
Converts string to double floating point

double strtod(const char *s, char **endptr);

Returns the value of s as a double, where s is
a sequence of characters.
//
Converts string to double floating point

double strtod(const char *s, char **endptr);

Prototype in stdlib.h

Returns the value of s as a double, where s is
a sequence of characters. The string must
match the following format:
gddsky 2002-01-01
  • 打赏
  • 举报
回复
在C++中
float x;
istrstream in("222.333");
in>>x;
panjet 2001-12-31
  • 打赏
  • 举报
回复
float result;
result=atof("120.4");

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧