C
int 转 string
- sprintf
int a = 1;
char strDst[256] = {0};
sprintf_s(strDst,256,"%d",a);
- itoa
int a = 1;
char strDst[256] = {0};
// 10代表使用十进制协议,默认使用十六进制
itoa(strDst,i,10);
string 转 int
- atoi
char *strDst = "123";
int a = atoi(strDst);
C++
int 转 string
int a = 5;
std::stringstream ssTemp;
ssTemp<<a;
std::string strDst=ssTemp.str();
string 转 int
int a = 0;
char *strData = "123";
stringstream stream(strData );
stream>>a;