您的位置:首页 > 其它

float 如何转化为字符串类型

2013-01-22 18:46 169 查看
对于float   f;
方法1:  char   buf[32];
snprintf(buf,   sizeof(buf),   "%f ",   f);
string   s   =   buf;
方法2:
#include   <stdlib.h>
char   buf[32];  _gcvt(f,   16,   buf);
string   s   =   buf;
方法3:  #include   <sstream>
ostringstream   oss;
oss   < <   f;  string   s   =   oss.str();
方法4:  //使用boost库:
string   s   =   boost::lexical_cast <string> (f);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: