对于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); 

 

相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-04-03
  • 2021-06-29
相关资源
相似解决方案