1、string转int

std::string str1="700"
 int bid_v1 = atoi(str1.c_str());


2、string转float

std::string str2="6.78"
float bid_p1 = atof(str2.c_str());


3、int 转string

int n =789;
char t[256];
sprintf(t, "%d", n);
string s(t)

 

4、double转char*

char str[255];
sprintf(str, "%f", 10.8); //将10.8转为字符串

相关文章:

  • 2021-08-20
  • 2022-12-23
  • 2021-07-22
  • 2021-10-12
  • 2021-12-24
  • 2021-10-04
  • 2022-02-13
  • 2022-12-23
猜你喜欢
  • 2021-10-24
  • 2021-04-24
  • 2021-11-02
  • 2021-05-30
  • 2021-09-18
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案