C++中string、int、char之间转换
1、string转int
1 string str="12345";
2 int b=atoi(str.c_str());
2、int转string
1 int num = 100;
2 char numStr[20] = {0};
3 sprintf(numStr, "%d", num);
4 string str = string(numStr);
3、char*转string
1 char* pChar = "test";
2 char temp[20] = {0};
3 sprintf(temp, "%s", pChar);
4 string str = string(temp);