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转为字符串
原文地址:https://www.cnblogs.com/briskzou/p/12083480.html
时间: 2024-12-10 21:15:19